Compare commits

..

43 Commits

Author SHA1 Message Date
icex2
5ae0b17517 Revert "Revert "chore: Bump to 5.50 for next development cycle""
Some checks failed
Build bemanitools / build (push) Has been cancelled
This reverts commit db1f8ccda4.
2025-06-09 20:46:23 +02:00
icex2
0d0e22de61 fix: Broken actions due to deprecation of download-artifact v2
Some checks failed
Build bemanitools / build (push) Has been cancelled
This was required to be updated already in April as v2 is now
fully unsupported by github
2025-06-09 20:44:50 +02:00
icex2
db1f8ccda4 Revert "chore: Bump to 5.50 for next development cycle"
This reverts commit 2a03204363.
2025-06-09 20:42:52 +02:00
icex2
2a03204363 chore: Bump to 5.50 for next development cycle 2025-06-09 20:34:57 +02:00
icex2
6f6fbcce56 chore: Update changelog for 4.49 release 2025-06-09 20:33:19 +02:00
icex2
7bfaf59c93 chore: Documentation consolidation and cleanup 2025-06-09 20:31:44 +02:00
icex2
1482183dd9 doc: Dev journal entry about IIDX engine and syncbook
Due to recent development of tools and discussions, this
is something that came up and has probably been overdue
for ages.

Document key concepts of how the iidx engine works regaring
rendering, game loop and (song) sync.

Add a “syncbook” that provides context and guidelines how
to configure any (modern) system to work properly with iidx.
2025-06-09 20:23:13 +02:00
Will Xyen
8d3c33dc77 iidxhook9: Add E drive to fshook 2025-06-09 20:18:36 +02:00
Will Xyen
384fad89e3 iidxhook9: add reverb ex fix 2025-06-09 20:18:36 +02:00
icex2
c67053f3d3 fix: Missing closing bracket (#336)
Some checks failed
Build bemanitools / build (push) Has been cancelled
Fix mistake that happened during conflict resolution
before the merge.
2025-02-19 19:49:09 +01:00
icex2
ccbd47428f feat(nvgpu): Add —overwrite-exists flag for profile creation (#335)
When running this in a script on startup to ensure
whatever configuration is required to be created is
created, this avoids several commands to first
check if the profile exists, delete it, then re-create it.
2025-02-19 19:45:43 +01:00
icex2
8b89748ccf fix(nvgpu): Initialize value of parameter to fix INVALID_ARGUMENT (#334)
As stated by the documentation in nvapi.h, path_info_count
must be set to the value 0 in this case.
2025-02-19 19:42:11 +01:00
icex2
9a7285bb91 fix(nvgpu): Missing error handling not returning (#333)
If fetching the configuration fails, don’t continue with
processing any non-existing data.
2025-02-19 19:41:06 +01:00
icex2
366f0090a9 chore: Remove TODO (#332)
Forgot to remove that after adressing the issue of needing
three calls in nvgpu to get the config data correctly.
2025-02-19 19:39:51 +01:00
icex2
d781905d83 feat: Extend monitor check tool, vsync and response time tests (#331)
Adding two more tests that have been proven very useful
for debugging monitor issues that caused problems with IIDX.

The vsync test flickers a text snippet between red and cyan on
every even and uneven frame. If vsync works correctly, the text
appears grey to the human eye. If there are issues like re-displaying
a previous frame or a dropped frame, this appears as the text
rendering red or cyan.

The response time test scrolls two simple blocks/lines vertically
to check if they creating ghosting/smearing on the display.

The tool now supports an interactive and command line mode.

Interactive mode is useful for running different tests on the setup
while the command line mode can be used to ran these tests
with fixed parameters and for a fixed amount of time, e.g. in a shell
script, for automation purpose.

The tool still has a few obvious imperfections like scaling issues on
different resolutions. Considering the basic functionality is given,
further improvements can follow in future iterations.
2025-02-19 19:38:31 +01:00
icex2
e0ff83f664 feat: d3d9-frame-graph-hook, add frame rate graph view (#330)
Some checks failed
Build bemanitools / build (push) Has been cancelled
Have a checkbox to switch to a frame graph focused view
which saves a bunch of math when it’s more useful to
focus on the frame/refresh rate than the frame time values.

Co-authored-by: icex2 <djh.icex2@gmail.com>
2025-02-13 15:10:05 +01:00
icex2
972acb5f0e feat: nvgpu, add option to enable gpu scaling (#329)
GPU scaling allows high quality upscaling of older games
to the native resolution of the screen. The output frame
quality is significantly sharper than the fairly simple
frame buffer upscaling of bemanitools.

Co-authored-by: icex2 <djh.icex2@gmail.com>
2025-02-13 15:03:34 +01:00
icex2
233df32372 feat: nvgpu, make test timeout parameter optional (#328)
10 seconds is what the nvidia control panel also
has for the test timeout. Can still be changed if
shorter or longer timeouts are desired, but 10
seconds should be a general fine timeout value
to have this optional.

Co-authored-by: icex2 <djh.icex2@gmail.com>
2025-02-13 14:51:02 +01:00
icex2
d07b2094e9 feat: d3d9-monitor-check add result-timeout-secs parameter (#327)
Allow changing the time in seconds how long the results
are being displayed before exiting

Co-authored-by: icex2 <djh.icex2@gmail.com>
2025-02-13 14:45:45 +01:00
icex2
7e1e9dabdb feat: d3d9-monitor-check allow skip results (#326)
Allow pressing ESC to skip results and not having
to wait for 5 secs

Co-authored-by: icex2 <djh.icex2@gmail.com>
2025-02-13 14:36:37 +01:00
icex2
6146f53ad5 feat: Improve d3d9-monitor-check command line args (#325)
Use more user-friendly seconds for total and warm-up time
instead of frames. Use the refresh rate to calculcate the
total frame count internally for the test.

Co-authored-by: icex2 <djh.icex2@gmail.com>
2025-02-13 14:31:47 +01:00
icex2
05d55024b6 feat: d3d9-monitor-check tool (#322)
Some checks are pending
Build bemanitools / build (push) Waiting to run
A separate application to run the infamous IIDX “monitor check”.

The on-screen output has been enhanced to provide more
detailed information about the on-going process. The tool
furthermore allows basic querying of adapter and adapter
modes information from the command line. These additional
options can be useful to gather more debug information
or select correct parameters for the monitor test from actually
supported mode parameters by the adapter.

The tool has been tested on an actual cabinet with nvgpu
setting different custom timings. The accuracy seems to be
even higher than what IIDX’s monitor check is actually showing.
For example, with a custom timing of 59.900, the tool yields 59.902.
Meanwhile, the monitor check of iidx 29 59.8981 hz to 59.8997 hz
on screen.

This doesn’t mean the game’s getting inaccurate values. The game
actually syncs and plays just fine. However, the game’s monitor check
cannot be used as a reference for “getting the avg. refresh rate”
value as an input parameter for other tools, e.g. chart patching with
btools.

Co-authored-by: icex2 <djh.icex2@gmail.com>
2025-02-12 19:39:19 +01:00
icex2
cc5c35064c feat: Bump iidxhook9 supported versions, EPOLIS “support" (#324)
Some checks failed
Build bemanitools / build (push) Has been cancelled
No changes required, just make support visible by reflecting
it in distribution package naming, documentation and
filenaming

Co-authored-by: icex2 <djh.icex2@gmail.com>
2025-02-11 15:35:28 +01:00
icex2
844286fde0 fix: Update upload-artifact from v2 to v4 to address deprecation
Some checks failed
Build bemanitools / build (push) Has been cancelled
v2 was deprecated a while ago and actions don't support it
since end of June. Migration to v4 is required to enable
github actions again
2025-02-08 23:59:23 +01:00
icex2
50aa6226a3 feat: Add separate d3d9-frame-graph-hook (#321)
Allow this to be hooked by any application with a d3d9
render backend. This is not compatible with d3d9ex.
2025-02-08 23:22:46 +01:00
icex2
ea29b44b70 feat: Add frame time performance graph imgui overlay (#319)
A overlay window showing the a frame time graph with
the current frame time, ~10 seconds of history as well
as reference lines for the current avg. and a configurable
target frame time.

This is considered a debug tool to support in any efforts
that are related to understanding current frame times
of the games. More specifically this can be used to asses
impact of any bemanitools hooking to the game’s main
(render) loop.
2025-02-08 23:21:27 +01:00
icex2
3090b9a029 feat: Add bt d3d9 hook specific imgui overlay (#318)
For now, we focus on internal overlays for bemanitools
that hook into an existing d3d9 context. The current
abstraction is fairly thin and should be fine as a start.

Implementations are called “components” and hook
up with a single frame_update function to execute
and logic and drawing updates with imgui
2025-02-08 23:19:49 +01:00
icex2
a85ce4bc96 feat: Integrate imgui library
Version 1.91.7 of the imgui library with the cimgui wrapper.

imgui allows us to easily create minimal and powerful UI for
use-cases like in-game overlays or separate tooling.

The additional wrappers cimgui_impl_dx9 and cimgui_impl_win32
were added to provide a full C linkage integration for the rest
of the code base.

Tweaks to the makefile were kept to a minimum but enable
compilation of C++ since imgui is C++ based.

Remark: At this point bemanitools itself is still to be kept a pure
C codebase. Due to the lack of proper module/library management
with the current build system in bemanitools 5, proper separation
of concerns and clean integration with external libraries isn’t
possible with reasonable effort.
2025-02-08 23:13:05 +01:00
icex2
b7d1659a46 feat: nvgpu tool for tweaking nvidia gpu driver settings
An open source re-implementation of the “NvDisplayConfigLDJ"
tool with additional enhancements.

This can be used to tweak your nvidia GPU driver settings to
create custom display timings to address IIDX’s requirement
if expecting proper display timings. This can also be used for
any legacy IIDX versions that even expect very specific display
timings, e.g. 59.95 or 60.05 hz.

Furthermore, creating application profiles allows further tweaks
to important GPU settings such as the current performance mode
setting. This is crucial to ensure the GPU is not going into any
kind of power saving states which results in non-smooth
scrolling during gameplay and micro stuttering that cannot
be measured on application level.
2025-02-08 23:04:10 +01:00
icex2
b64dea0849 feat: Add iidxio-async implementation
A shim library implementing the same concept as the already
existing ddrio-async library. The iidxio implementation takes
another iidxio library and runs it asynchronously which may
improve performance for certain iidxio implementations,
e.g. if the send and receive functions are driving actual IO
calls synchrously and are expensive.

This is not a replacement for a well engineered and proper
implementation of a iidxio library for any specific use-case.
It does not fix bad performance of existing implementations,
i.e. if the poll rate is too low because actual IO is too slow.

Use with caution and know why and when you need to use
it.
2025-02-08 22:51:46 +01:00
icex2
64381a84c5 feat: Add warning if vsync is not enabled
Something I ran into by accident during testing and
development that I had vsync turned off by accident.
Increase visibility in the logs.
2025-02-08 22:49:42 +01:00
Will Xyen
48668837a8 camhook: fix camhook for new style camera detection 2024-05-21 22:29:11 -07:00
Will Xyen
8307837995 camhook: split cam-detect code to different file 2024-05-21 22:29:11 -07:00
Will Xyen
a03c4e0d93 iidxhook9: add fs hook for F drive 2024-05-11 17:17:40 -07:00
garbage
ca42257fa2 iidxhook-util: Add domain check to my_gethostbyname func 2024-03-25 14:16:47 +01:00
garbage
f7142df84d iidxhook-util: Remove inet_addr hook 2024-03-25 14:16:47 +01:00
garbage
7d397dc54c iidxhook3: Add hook for ea3_boot func 2024-03-25 14:16:47 +01:00
icex2
2d4d5fa535 feat(avs-util): Add helper to translate property errors 2024-02-25 09:36:24 +01:00
icex2
e81bd6f9cd fix(avs): Incorrect function signature
After getting doubts, I looked this one up again on the
assembly. The decompiled output confused me
and no actual value is being returned there.
2024-02-25 09:35:30 +01:00
icex2
a4b3f92935 feat(avs): Add property get and clear error functions
Use these to improve error handling by allowing
one to provide additional error information on
property related operations.
2024-02-25 09:23:02 +01:00
icex2
6a98ce1f59 feat(dev): Add a separate docker dev container
Improve the development experience by providing
an additional docker container that can be started
and used as an interactive development environment.
It provides all the tools and a stable environment
for building (identical to the build container).
2024-02-25 09:14:59 +01:00
icex2
5833197b03 fix(hook): Add missing hook_table_revert impl
Allow hooks to cleanup when they are shut down.
2024-02-25 09:09:12 +01:00
icex2
7ee9a2e219 fix(dist): Incorrect versioning for ddr distribution packages
Apparently forgotten to get updated to reflect the
currently supported versions correctly.
2024-02-25 08:52:00 +01:00
167 changed files with 122563 additions and 2240 deletions

View File

@@ -30,7 +30,7 @@ jobs:
cd .. cd ..
- name: "Upload artifact" - name: "Upload artifact"
uses: "actions/upload-artifact@v2" uses: "actions/upload-artifact@v4"
with: with:
name: bemanitools-${{ github.sha }} name: bemanitools-${{ github.sha }}
retention-days: 90 retention-days: 90

View File

@@ -35,7 +35,7 @@ jobs:
cd .. cd ..
- name: "Upload artifact" - name: "Upload artifact"
uses: "actions/upload-artifact@v2" uses: "actions/upload-artifact@v4"
with: with:
name: bemanitools-${{ github.sha }} name: bemanitools-${{ github.sha }}
retention-days: 90 retention-days: 90
@@ -49,7 +49,7 @@ jobs:
steps: steps:
# This already extracts the contents of the artifact # This already extracts the contents of the artifact
- name: "Download artifact" - name: "Download artifact"
uses: "actions/download-artifact@v2" uses: "actions/download-artifact@v4"
with: with:
name: bemanitools-${{ github.sha }} name: bemanitools-${{ github.sha }}

View File

@@ -3,12 +3,37 @@
Note for CI/CD: Ensure the version formatting in the sections is kept identical to the versions Note for CI/CD: Ensure the version formatting in the sections is kept identical to the versions
given in tags. The pipeline will pick this up and cuts out the relevant section for release notes. given in tags. The pipeline will pick this up and cuts out the relevant section for release notes.
## 5.49 ## 5.50
### Features ### Features
### Fixes ### Fixes
## 5.49
### Features
- Major overhaul of [IIDX sync and performance settings](doc/iidxhook/iidx-syncbook.md)
documentation. Supports users in configuring their systems to run any IIDX version with proper
display timings, smooth frame rates and sync game-play
- Add `iidxio-async.dll` wrapper/shim library to drive another iidxio in a dedicated IO thread, see
[documentation](doc/iidxhook/iidxio-async.md) for details
- Add `nvgpu` tool to configure NVIDIA GPUs and create a custom timing profile, see
[documentation](doc/tools/nvgpu.md) for details
- Add `d3d9-frame-graph-hook.dll` that can be added as a hook to
either `launcher.exe` or `inject.exe` to display a graph of the frame times of the game's render
for debugging and performance analysis
- feat: Add `d3d9-monitor-check` tool to run different music game relevant monitor tests including
a re-implementation of the infamous IIDX “monitor check” as a separate tool for testing and
debugging. See [documentation](doc/tools/d3d9-monitor-check.md) for details
### Fixes
- iidxhook9: Work around reverb issue from Windows 26100.3476
- iidxhook9: fix camhook for new style camera detection
- `cam.port_layout` added to .conf files of iidx 27 to 30
- In general, a lot of internal cleanup
## 5.48 ## 5.48
### Features ### Features

View File

@@ -30,7 +30,7 @@ cppflags := -I src -I src/main -I src/test -DGITREV=$(gitrev)
cflags := -O2 -pipe -ffunction-sections -fdata-sections \ cflags := -O2 -pipe -ffunction-sections -fdata-sections \
-Wall -std=c99 -DPSAPI_VERSION=1 -Wall -std=c99 -DPSAPI_VERSION=1
cflags_release := -Werror cflags_release := -Werror
ldflags := -Wl,--gc-sections -static-libgcc ldflags := -Wl,--gc-sections -static -static-libgcc -static-libstdc++
# #
# The first target that GNU Make encounters becomes the default target. # The first target that GNU Make encounters becomes the default target.
@@ -156,8 +156,10 @@ modules := $(dlls) $(exes) $(libs) $(avsdlls) $(avsexes) $(testdlls) $(testexes
define t_moddefs define t_moddefs
cppflags_$3 += $(cppflags) -DBUILD_MODULE=$3 cppflags_$3 += $(cppflags) -DBUILD_MODULE=$3
cxxflags_$3 += $(cxxflags) # Add C++-specific flags
cflags_$3 += $(cflags) cflags_$3 += $(cflags)
release: cflags_$3 += $(cflags_release) release: cflags_$3 += $(cflags_release)
release: cxxflags_$3 += $(cxxflags_release) # Add C++-specific release flags
ldflags_$3 += $(ldflags) ldflags_$3 += $(ldflags)
srcdir_$3 ?= src/main/$3 srcdir_$3 ?= src/main/$3
@@ -212,9 +214,11 @@ abslib_$1_$2_$3 := $$(libs_$3:%=$$(bindir_$1_indep)/lib%.a)
absdpl_$1_$2_$3 := $$(deplibs_$3:%=$$(bindir_$1_$2)/lib%.a) absdpl_$1_$2_$3 := $$(deplibs_$3:%=$$(bindir_$1_$2)/lib%.a)
objdir_$1_$2_$3 := $(objdir)/$$(subdir_$1_$2)/$3 objdir_$1_$2_$3 := $(objdir)/$$(subdir_$1_$2)/$3
obj_$1_$2_$3 := $$(src_$3:%.c=$$(objdir_$1_$2_$3)/%.o) \ obj_$1_$2_$3 := $$(src_$3:%.c=$$(objdir_$1_$2_$3)/%.o) \
$$(cppsrc_$3:%.cpp=$$(objdir_$1_$2_$3)/%.o) \
$$(rc_$3:%.rc=$$(objdir_$1_$2_$3)/%_rc.o) $$(rc_$3:%.rc=$$(objdir_$1_$2_$3)/%_rc.o)
deps += $$(src_$3:%.c=$$(depdir_$1_$2_$3)/%.d) deps += $$(src_$3:%.c=$$(depdir_$1_$2_$3)/%.d) \
$$(cppsrc_$3:%.cpp=$$(depdir_$1_$2_$3)/%.d)
$$(depdir_$1_$2_$3): $$(depdir_$1_$2_$3):
$(V)mkdir -p $$@ $(V)mkdir -p $$@
@@ -223,16 +227,24 @@ $$(objdir_$1_$2_$3):
$(V)mkdir -p $$@ $(V)mkdir -p $$@
$$(volatile_$3:%.c=$$(objdir_$1_$2_$3)/%.o): FORCE $$(volatile_$3:%.c=$$(objdir_$1_$2_$3)/%.o): FORCE
$$(volatile_cpp_$3:%.cpp=$$(objdir_$1_$2_$3)/%.o): FORCE
$$(objdir_$1_$2_$3)/%.o: $$(srcdir_$3)/%.c \ $$(objdir_$1_$2_$3)/%.o: $$(srcdir_$3)/%.c \
| $$(depdir_$1_$2_$3) $$(objdir_$1_$2_$3) | $$(depdir_$1_$2_$3) $$(objdir_$1_$2_$3)
$(V)echo ... $$@ $(V)echo \(.c\) ... $$@
$(V)$$(toolchain_$1)gcc $$(cflags_$3) $$(cppflags_$3) \ $(V)$$(toolchain_$1)gcc $$(cflags_$3) $$(cppflags_$3) \
-MMD -MF $$(depdir_$1_$2_$3)/$$*.d -MT $$@ -MP \ -MMD -MF $$(depdir_$1_$2_$3)/$$*.d -MT $$@ -MP \
-DAVS_VERSION=$2 -c -o $$@ $$< -DAVS_VERSION=$2 -c -o $$@ $$<
$$(objdir_$1_$2_$3)/%.o: $$(srcdir_$3)/%.cpp \
| $$(depdir_$1_$2_$3) $$(objdir_$1_$2_$3)
$(V)echo \(.cpp\) ... $$@
$(V)$$(toolchain_$1)g++ $$(cxxflags_$3) $$(cppflags_$3) \
-MMD -MF $$(depdir_$1_$2_$3)/$$*.d -MT $$@ -MP \
-DAVS_VERSION=$2 -c -o $$@ $$<
$$(objdir_$1_$2_$3)/%_rc.o: $$(srcdir_$3)/%.rc $$(objdir_$1_$2_$3)/%_rc.o: $$(srcdir_$3)/%.rc
$(V)echo ... $$@ [windres] $(V)echo \(.rc\) ... $$@ [windres]
$(V)$$(toolchain_$1)windres $$(cppflags_$3) $$< $$@ $(V)$$(toolchain_$1)windres $$(cppflags_$3) $$< $$@
endef endef
@@ -244,7 +256,7 @@ define t_archive
$(t_compile) $(t_compile)
$$(bindir_$1_$2)/lib$3.a: $$(obj_$1_$2_$3) | $$(bindir_$1_$2) $$(bindir_$1_$2)/lib$3.a: $$(obj_$1_$2_$3) | $$(bindir_$1_$2)
$(V)echo ... $$@ $(V)echo \(.a\) ... $$@
$(V)$$(toolchain_$1)ar r $$@ $$^ 2> /dev/null $(V)$$(toolchain_$1)ar r $$@ $$^ 2> /dev/null
$(V)$$(toolchain_$1)ranlib $$@ $(V)$$(toolchain_$1)ranlib $$@
@@ -262,8 +274,8 @@ implib_$1_$2_$3 := $$(bindir_$1_$2)/lib$3.a
$$(dll_$1_$2_$3) $$(implib_$1_$2_$3): $$(obj_$1_$2_$3) $$(abslib_$1_$2_$3) \ $$(dll_$1_$2_$3) $$(implib_$1_$2_$3): $$(obj_$1_$2_$3) $$(abslib_$1_$2_$3) \
$$(absdpl_$1_$2_$3) \ $$(absdpl_$1_$2_$3) \
$$(srcdir_$3)/$3.def | $$(bindir_$1_$2) $$(srcdir_$3)/$3.def | $$(bindir_$1_$2)
$(V)echo ... $$(dll_$1_$2_$3) $(V)echo \(.dll\) ... $$(dll_$1_$2_$3)
$(V)$$(toolchain_$1)gcc -shared \ $(V)$$(toolchain_$1)g++ -shared \
-o $$(dll_$1_$2_$3) -Wl,--out-implib,$$(implib_$1_$2_$3) \ -o $$(dll_$1_$2_$3) -Wl,--out-implib,$$(implib_$1_$2_$3) \
-Wl,--start-group $$^ -Wl,--end-group $$(ldflags_$3) -Wl,--start-group $$^ -Wl,--end-group $$(ldflags_$3)
$(V)$$(toolchain_$1)strip $$(dll_$1_$2_$3) $(V)$$(toolchain_$1)strip $$(dll_$1_$2_$3)
@@ -281,8 +293,8 @@ exe_$1_$2_$3 := $$(bindir_$1_$2)/$3.exe
$$(exe_$1_$2_$3): $$(obj_$1_$2_$3) $$(abslib_$1_$2_$3) $$(absdpl_$1_$2_$3) \ $$(exe_$1_$2_$3): $$(obj_$1_$2_$3) $$(abslib_$1_$2_$3) $$(absdpl_$1_$2_$3) \
| $$(bindir_$1_$2) | $$(bindir_$1_$2)
$(V)echo ... $$@ $(V)echo \(.exe\) ... $$@
$(V)$$(toolchain_$1)gcc -o $$@ $$^ $$(ldflags_$3) $(V)$$(toolchain_$1)g++ -o $$@ $$^ $$(ldflags_$3)
$(V)$$(toolchain_$1)strip $$@ $(V)$$(toolchain_$1)strip $$@
endef endef
@@ -294,7 +306,7 @@ define t_import
impdef_$1_$2_$3 ?= src/imports/import_$1_$2_$3.def impdef_$1_$2_$3 ?= src/imports/import_$1_$2_$3.def
$$(bindir_$1_$2)/lib$3.a: $$(impdef_$1_$2_$3) | $$(bindir_$1_$2) $$(bindir_$1_$2)/lib$3.a: $$(impdef_$1_$2_$3) | $$(bindir_$1_$2)
$(V)echo ... $$@ [dlltool] $(V)echo \(.a\) ... $$@ [dlltool]
$(V)$$(toolchain_$1)dlltool --kill-at -l $$@ -d $$< $(V)$$(toolchain_$1)dlltool --kill-at -l $$@ -d $$<
endef endef

View File

@@ -100,7 +100,8 @@ include src/main/bstio/Module.mk
include src/main/camhook/Module.mk include src/main/camhook/Module.mk
include src/main/cconfig/Module.mk include src/main/cconfig/Module.mk
include src/main/config/Module.mk include src/main/config/Module.mk
include src/main/core/Module.mk include src/main/d3d9-frame-graph-hook/Module.mk
include src/main/d3d9-monitor-check/Module.mk
include src/main/d3d9-util/Module.mk include src/main/d3d9-util/Module.mk
include src/main/d3d9exhook/Module.mk include src/main/d3d9exhook/Module.mk
include src/main/ddrhook-util/Module.mk include src/main/ddrhook-util/Module.mk
@@ -155,11 +156,15 @@ include src/main/iidxhook6/Module.mk
include src/main/iidxhook7/Module.mk include src/main/iidxhook7/Module.mk
include src/main/iidxhook8/Module.mk include src/main/iidxhook8/Module.mk
include src/main/iidxhook9/Module.mk include src/main/iidxhook9/Module.mk
include src/main/iidxio-async/Module.mk
include src/main/iidxio-bio2/Module.mk include src/main/iidxio-bio2/Module.mk
include src/main/iidxio-ezusb/Module.mk include src/main/iidxio-ezusb/Module.mk
include src/main/iidxio-ezusb2/Module.mk include src/main/iidxio-ezusb2/Module.mk
include src/main/iidxio/Module.mk include src/main/iidxio/Module.mk
include src/main/iidxiotest/Module.mk include src/main/iidxiotest/Module.mk
include src/main/imgui/Module.mk
include src/main/imgui-bt/Module.mk
include src/main/imgui-debug/Module.mk
include src/main/inject/Module.mk include src/main/inject/Module.mk
include src/main/jbio-magicbox/Module.mk include src/main/jbio-magicbox/Module.mk
include src/main/jbio-p4io/Module.mk include src/main/jbio-p4io/Module.mk
@@ -173,6 +178,8 @@ include src/main/jbhook3/Module.mk
include src/main/launcher/Module.mk include src/main/launcher/Module.mk
include src/main/mempatch-hook/Module.mk include src/main/mempatch-hook/Module.mk
include src/main/mm/Module.mk include src/main/mm/Module.mk
include src/main/nv/Module.mk
include src/main/nvgpu/Module.mk
include src/main/p3io/Module.mk include src/main/p3io/Module.mk
include src/main/p3iodrv/Module.mk include src/main/p3iodrv/Module.mk
include src/main/p3ioemu/Module.mk include src/main/p3ioemu/Module.mk
@@ -233,6 +240,9 @@ $(zipdir)/tools.zip: \
build/bin/indep-32/ezusb2-dbg-hook.dll \ build/bin/indep-32/ezusb2-dbg-hook.dll \
build/bin/indep-32/ezusb2-tool.exe \ build/bin/indep-32/ezusb2-tool.exe \
build/bin/indep-32/ezusb-tool.exe \ build/bin/indep-32/ezusb-tool.exe \
build/bin/indep-32/nvgpu.exe \
build/bin/indep-32/d3d9-frame-graph-hook.dll \
build/bin/indep-32/d3d9-monitor-check.exe \
| $(zipdir)/ | $(zipdir)/
$(V)echo ... $@ $(V)echo ... $@
$(V)zip -j $@ $^ $(V)zip -j $@ $^
@@ -247,6 +257,9 @@ $(zipdir)/tools-x64.zip: \
build/bin/indep-64/iidx-ezusb2-exit-hook.dll \ build/bin/indep-64/iidx-ezusb2-exit-hook.dll \
build/bin/indep-64/jbiotest.exe \ build/bin/indep-64/jbiotest.exe \
build/bin/indep-64/mempatch-hook.dll \ build/bin/indep-64/mempatch-hook.dll \
build/bin/indep-64/nvgpu.exe \
build/bin/indep-64/d3d9-frame-graph-hook.dll \
build/bin/indep-64/d3d9-monitor-check.exe \
| $(zipdir)/ | $(zipdir)/
$(V)echo ... $@ $(V)echo ... $@
$(V)zip -j $@ $^ $(V)zip -j $@ $^
@@ -293,7 +306,7 @@ $(zipdir)/iidx-13.zip: \
$(V)zip -j $@ $^ $(V)zip -j $@ $^
$(zipdir)/iidx-14-to-17.zip: \ $(zipdir)/iidx-14-to-17.zip: \
build/bin/avs2_0-32/iidxhook3.dll \ build/bin/avs2_803-32/iidxhook3.dll \
build/bin/indep-32/config.exe \ build/bin/indep-32/config.exe \
build/bin/indep-32/eamio.dll \ build/bin/indep-32/eamio.dll \
build/bin/indep-32/geninput.dll \ build/bin/indep-32/geninput.dll \
@@ -432,7 +445,7 @@ $(zipdir)/iidx-25-to-26.zip: \
$(V)echo ... $@ $(V)echo ... $@
$(V)zip -j $@ $^ $(V)zip -j $@ $^
$(zipdir)/iidx-27-to-30.zip: \ $(zipdir)/iidx-27-to-31.zip: \
build/bin/avs2_1700-64/iidxhook9.dll \ build/bin/avs2_1700-64/iidxhook9.dll \
build/bin/avs2_1700-64/launcher.exe \ build/bin/avs2_1700-64/launcher.exe \
build/bin/indep-64/config.exe \ build/bin/indep-64/config.exe \
@@ -445,10 +458,12 @@ $(zipdir)/iidx-27-to-30.zip: \
dist/iidx/gamestart-28.bat \ dist/iidx/gamestart-28.bat \
dist/iidx/gamestart-29.bat \ dist/iidx/gamestart-29.bat \
dist/iidx/gamestart-30.bat \ dist/iidx/gamestart-30.bat \
dist/iidx/gamestart-31.bat \
dist/iidx/iidxhook-27.conf \ dist/iidx/iidxhook-27.conf \
dist/iidx/iidxhook-28.conf \ dist/iidx/iidxhook-28.conf \
dist/iidx/iidxhook-29.conf \ dist/iidx/iidxhook-29.conf \
dist/iidx/iidxhook-30.conf \ dist/iidx/iidxhook-30.conf \
dist/iidx/iidxhook-31.conf \
dist/iidx/vefx.txt \ dist/iidx/vefx.txt \
| $(zipdir)/ | $(zipdir)/
$(V)echo ... $@ $(V)echo ... $@
@@ -457,6 +472,7 @@ $(zipdir)/iidx-27-to-30.zip: \
$(zipdir)/iidx-hwio-x86.zip: \ $(zipdir)/iidx-hwio-x86.zip: \
build/bin/indep-32/aciomgr.dll \ build/bin/indep-32/aciomgr.dll \
build/bin/indep-32/eamio-icca.dll \ build/bin/indep-32/eamio-icca.dll \
build/bin/indep-32/iidxio-async.dll \
build/bin/indep-32/iidxio-bio2.dll \ build/bin/indep-32/iidxio-bio2.dll \
build/bin/indep-32/iidxio-ezusb.dll \ build/bin/indep-32/iidxio-ezusb.dll \
build/bin/indep-32/iidxio-ezusb2.dll \ build/bin/indep-32/iidxio-ezusb2.dll \
@@ -470,6 +486,7 @@ $(zipdir)/iidx-hwio-x86.zip: \
$(zipdir)/iidx-hwio-x64.zip: \ $(zipdir)/iidx-hwio-x64.zip: \
build/bin/indep-64/aciomgr.dll \ build/bin/indep-64/aciomgr.dll \
build/bin/indep-64/eamio-icca.dll \ build/bin/indep-64/eamio-icca.dll \
build/bin/indep-64/iidxio-async.dll \
build/bin/indep-64/iidxio-bio2.dll \ build/bin/indep-64/iidxio-bio2.dll \
build/bin/indep-64/iidxio-ezusb.dll \ build/bin/indep-64/iidxio-ezusb.dll \
build/bin/indep-64/iidxio-ezusb2.dll \ build/bin/indep-64/iidxio-ezusb2.dll \
@@ -852,7 +869,7 @@ $(BUILDDIR)/bemanitools.zip: \
$(zipdir)/iidx-20-cn.zip \ $(zipdir)/iidx-20-cn.zip \
$(zipdir)/iidx-21-to-24.zip \ $(zipdir)/iidx-21-to-24.zip \
$(zipdir)/iidx-25-to-26.zip \ $(zipdir)/iidx-25-to-26.zip \
$(zipdir)/iidx-27-to-30.zip \ $(zipdir)/iidx-27-to-31.zip \
$(zipdir)/iidx-hwio-x86.zip \ $(zipdir)/iidx-hwio-x86.zip \
$(zipdir)/iidx-hwio-x64.zip \ $(zipdir)/iidx-hwio-x64.zip \
$(zipdir)/jb-01.zip \ $(zipdir)/jb-01.zip \

View File

@@ -1,6 +1,6 @@
# Bemanitools 5 # Bemanitools 5
Version: `5.49` Version: `5.50`
[Changelog](CHANGELOG.md) [Changelog](CHANGELOG.md)
@@ -71,6 +71,7 @@ The following games are supported with their corresponding hook-libraries.
- Beatmania IIDX 28 BISTROVER (`iidx-27-to-30.zip`): [iidxhook9](doc/iidxhook/iidxhook9.md) - Beatmania IIDX 28 BISTROVER (`iidx-27-to-30.zip`): [iidxhook9](doc/iidxhook/iidxhook9.md)
- Beatmania IIDX 29 CASTHOUR (`iidx-27-to-30.zip`): [iidxhook9](doc/iidxhook/iidxhook9.md) - Beatmania IIDX 29 CASTHOUR (`iidx-27-to-30.zip`): [iidxhook9](doc/iidxhook/iidxhook9.md)
- Beatmania IIDX 30 RESIDENT (`iidx-27-to-30.zip`): [iidxhook9](doc/iidxhook/iidxhook9.md) - Beatmania IIDX 30 RESIDENT (`iidx-27-to-30.zip`): [iidxhook9](doc/iidxhook/iidxhook9.md)
- Beatmania IIDX 31 EPOLIS (`iidx-27-to-31.zip`): [iidxhook9](doc/iidxhook/iidxhook9.md)
- [jubeat](doc/jbhook/README.md) - [jubeat](doc/jbhook/README.md)
- jubeat (`jb-01.zip`): [jbhook1](doc/jbhook/jbhook1.md) - jubeat (`jb-01.zip`): [jbhook1](doc/jbhook/jbhook1.md)
- jubeat ripples (`jb-02.zip`): [jbhook1](doc/jbhook/jbhook1.md) - jubeat ripples (`jb-02.zip`): [jbhook1](doc/jbhook/jbhook1.md)
@@ -119,9 +120,12 @@ The following games are supported with their corresponding hook-libraries.
- [extiotest](doc/tools/extiotest.md) - [extiotest](doc/tools/extiotest.md)
- [aciotest](doc/tools/aciotest.md): Command line tool to quickly test ACIO devices - [aciotest](doc/tools/aciotest.md): Command line tool to quickly test ACIO devices
- config: UI input/output configuration tool when using the default bemanitools API (geninput) - config: UI input/output configuration tool when using the default bemanitools API (geninput)
- [d3d9-monitor-check](doc/tools/d3d9-monitor-check.md): Command line tool to check the monitor refresh rate of the
current GPU + monitor configuration
- ir-beat-patch-9/10: Patch the IR beat phase on IIDX 9 and 10 - ir-beat-patch-9/10: Patch the IR beat phase on IIDX 9 and 10
- [mempatch-hook](doc/tools/mempatch-hook.md): Patch raw memory locations in the target process - [mempatch-hook](doc/tools/mempatch-hook.md): Patch raw memory locations in the target process
based on the provided configuration based on the provided configuration
- [nvgpu](doc/tools/nvgpu.md): Command line tool to configure and tweak the NVIDIA GPU driver
- [pcbidgen](doc/tools/pcbidgen.md): Konami PCBID generator tool - [pcbidgen](doc/tools/pcbidgen.md): Konami PCBID generator tool
- [ViGEm clients](doc/vigem/README.md): Expose BT5 APIs as XBOX game controllers to play any games - [ViGEm clients](doc/vigem/README.md): Expose BT5 APIs as XBOX game controllers to play any games
with real cabinet hardware. with real cabinet hardware.

16
dist/iidx/gamestart-31.bat vendored Normal file
View File

@@ -0,0 +1,16 @@
@echo off
cd /d %~dp0
if not exist dev mkdir dev
if not exist dev\e mkdir dev\e
if not exist dev\g mkdir dev\g
if not exist dev\nvram mkdir dev\nvram
if not exist dev\raw mkdir dev\raw
if not exist dev\raw\log mkdir dev\raw\log
if not exist dev\raw\fscache mkdir dev\raw\fscache
for /R prop\defaults %%D in (*.*) do (
if not exist dev\nvram\%%~nxD copy /y prop\defaults\%%~nxD dev\nvram
)
modules\launcher -H 134217728 -B iidxhook9.dll bm2dx.dll --config iidxhook-31.conf %*

View File

@@ -22,6 +22,9 @@ io.tt_multiplier=1.0
# Disables the camera emulation # Disables the camera emulation
cam.disable_emu=true cam.disable_emu=true
# Camera port layout (0 = LDJ, 1 = CLDJ/TDJ-JA, 2 = TDJ-JB)
cam.port_layout=1
# Disable camera 1. Use, i.e., if you only have one camera and want it to be mapped to camera 2 ingame. # Disable camera 1. Use, i.e., if you only have one camera and want it to be mapped to camera 2 ingame.
cam.disable_camera1=false cam.disable_camera1=false

View File

@@ -22,6 +22,9 @@ io.tt_multiplier=1.0
# Disables the camera emulation # Disables the camera emulation
cam.disable_emu=true cam.disable_emu=true
# Camera port layout (0 = LDJ, 1 = CLDJ/TDJ-JA, 2 = TDJ-JB)
cam.port_layout=1
# Disable camera 1. Use, i.e., if you only have one camera and want it to be mapped to camera 2 ingame. # Disable camera 1. Use, i.e., if you only have one camera and want it to be mapped to camera 2 ingame.
cam.disable_camera1=false cam.disable_camera1=false

View File

@@ -22,6 +22,9 @@ io.tt_multiplier=1.0
# Disables the camera emulation # Disables the camera emulation
cam.disable_emu=true cam.disable_emu=true
# Camera port layout (0 = LDJ, 1 = CLDJ/TDJ-JA, 2 = TDJ-JB)
cam.port_layout=1
# Disable camera 1. Use, i.e., if you only have one camera and want it to be mapped to camera 2 ingame. # Disable camera 1. Use, i.e., if you only have one camera and want it to be mapped to camera 2 ingame.
cam.disable_camera1=true cam.disable_camera1=true

View File

@@ -22,6 +22,9 @@ io.tt_multiplier=1.0
# Disables the camera emulation # Disables the camera emulation
cam.disable_emu=true cam.disable_emu=true
# Camera port layout (0 = LDJ, 1 = CLDJ/TDJ-JA, 2 = TDJ-JB)
cam.port_layout=1
# Disable camera 1. Use, i.e., if you only have one camera and want it to be mapped to camera 2 ingame. # Disable camera 1. Use, i.e., if you only have one camera and want it to be mapped to camera 2 ingame.
cam.disable_camera1=true cam.disable_camera1=true

84
dist/iidx/iidxhook-31.conf vendored Normal file
View File

@@ -0,0 +1,84 @@
# Disable card reader emulation and enable usage of real card reader hardware on COM1 (for games supporting slotted readers)
io.disable_card_reader_emu=false
# Disable BIO2 emulation and enable usage of real BIO2 hardware
io.disable_bio2_emu=false
# Disables the poll limiter, warning very high CPU usage may arise
io.disable_poll_limiter=false
# Lightning cab mode (requires additional IO emulation)
io.lightning_mode=false
# Disable camera connection
io.disable_cams=true
# Disables the built in file hooks, requiring manual file creation
io.disable_file_hooks=false
# Turntable sensitivity multiplier (1.0 is default)
io.tt_multiplier=1.0
# Disables the camera emulation
cam.disable_emu=true
# Disable camera 1. Use, i.e., if you only have one camera and want it to be mapped to camera 2 ingame.
cam.disable_camera1=true
# Disable camera 2. Use, i.e., if you have more than one camera but only want to map camera 1 ingame.
cam.disable_camera2=false
# Override camera device ID detection (copy from device manager, do not escape)
cam.device_id1=
# Override camera device ID detection (copy from device manager, do not escape)
cam.device_id2=
# Run the game in a framed window (requires windowed option)
gfx.framed=true
# Run the game windowed
gfx.windowed=false
# Confine mouse cursor to window
gfx.confined=false
# Windowed width, -1 for default size
gfx.window_width=-1
# Windowed height, -1 for default size
gfx.window_height=-1
# Windowed X, -1 for default X position
gfx.window_x=-1
# Windowed Y, -1 for default Y position
gfx.window_y=-1
# Forced refresh rate, -1 to not force any (try 59 or 60 if monitor check fails to lock on high refresh rate monitors)
gfx.forced_refresh_rate=-1
# D3D9ex device adapter (monitor), -1 to use default, 0, 1, 2 etc. to use specified adapter
gfx.device_adapter=-1
# Orientation to force monitor into, -1 to use default, 0, 1, 2, 3 to do 0, 90, 180, 270 degrees
gfx.force_orientation=-1
# Force a screen resolution (width), -1 to disable. Use this if the game does not auto detect your monitor's resolution properly, e.g. 1368x768 instead of 1280x720.
gfx.force_screen_res.width=-1
# Force a screen resolution (height), -1 to disable. Use this if the game does not auto detect your monitor's resolution properly, e.g. 1368x768 instead of 1280x720.
gfx.force_screen_res.height=-1
# IP of adapter to force override with
adapter.override_ip=
# Force ASIO audio mode/device (if applicable / TDJ default)
asio.force_asio=false
# Force WASAPI audio mode (if applicable / LDJ default)
asio.force_wasapi=true
# The ASIO device name to use
asio.device_name=XONAR SOUND CARD(64)

View File

@@ -0,0 +1,319 @@
# IIDX engine overview and how game-play is impacted by hardware and software
Date: 2025-02-09 Author: icex2
This document provides information and explains the following:
* A sort-of taxonomy of the different major IIDX game engine versions
* How the core game-play part of the engine works regarding
* Threading model
* Main render loop
* Timing and synchronization
The goal is to capture key knowledge about how the game's engine works to enable a better
understanding for developing bemanitools and how certain features can impact performance and
synchronization during game-play.
This document is not claiming to be complete or 100% accurate. It is based on my own personal
research and understanding of the IIDX game engine. It is very likely that some of the information
is wrong or misunderstood. Feel free to raise any questions or concerns in an issue as I want
this document to be as accurate as possible.
## Taxonomy of IIDX game engine versions
With every version, there have been numerous changes and improvements to the game engine. The
following is a rough taxonomy that is focused on cabinet and hardware changes. As these are likely
the main driver for key changes to the software and game engine, they create fairly distinct
stages throughout the different versions of the game. The key attributes to be considered here are:
* Main PCB
* IO board
* Monitor
All of these had significant impact on key software features appearing or changing.
### Twinkle hardware era: 1st Style to 8th Style
* [Twinkle PCB](https://github.com/shizmob/arcade-docs/blob/main/konami/boards.md#twinkle)
* [Original rear projection monitor](https://github.com/shizmob/arcade-docs/blob/main/konami/products.md#iidx-rear-projection-monitor)
* Homogenous hardware and software
### 1st gen PC-based upgrade only: 9th Style
* 9th Style came as an upgrade kit only to existing twinkle-based cabinet hardware
* [KNM-845G3-A02 PCB](https://github.com/shizmob/arcade-docs/blob/main/konami/boards.md#knm-845g3-a02)
* [C02 EZUSB FX USB IO board](https://github.com/shizmob/arcade-docs/blob/main/konami/io.md#gec02-pwbaa)
* Magnetic card readers connected to ezusb IO board
### 1st gen PC-based with dedicated cabinet: 10th Style to DistorteD (13)
* From here on, old cabinets that received the "Twinkle hardware" upgrade kit could always receive software only
upgrades
* [CRT monitor](https://github.com/shizmob/arcade-docs/blob/main/konami/products.md#iidx-crt-monitor) with new dedicated
cabinets
* [D01 EZUSB FX USB IO board](https://github.com/shizmob/arcade-docs/blob/main/konami/io.md#d01-io)
* Slotted card readers starting version 13
### 2nd gen PC: GOLD (14) to Lincle (19)
* [FAB-e945-KN205](https://github.com/shizmob/arcade-docs/blob/main/konami/boards.md#fab-e945-kn205)
* All prior cabinet configurations can be upgraded with a PCB and software upgrade
* New LCD monitor starting version 15
* Further variants of the LCD monitor appear starting version 18
* [IO2 EZUSB FX2 USB IO board](https://github.com/shizmob/arcade-docs/blob/main/konami/io.md#usbio2) introduced with
version 14
* Switch to wave pass readers on version 19
### 3rd gen PC: Tricoro (20) to Sinobuz (24)
* All prior cabinet configurations can be upgraded with a PCB and software upgrade
* [ADE-HM65](https://github.com/shizmob/arcade-docs/blob/main/konami/boards.md#hm65)
* Game engine supports HD mode (720p)
* Many new LCD monitor variants appear with every new version
### 4th gen PC: CANNON BALLERS (25) to RESIDENT (30)
* All prior cabinet configurations can be upgraded with a PCB and software upgrade
* [ADE-6291](https://github.com/shizmob/arcade-docs/blob/main/konami/boards.md#ade-6291)
* [BIO2 IO board](https://github.com/shizmob/arcade-docs/blob/main/konami/boards.md#hm65)
* Upgrade cabinets required the [BIO2 sub-IO board](https://github.com/shizmob/arcade-docs/blob/main/konami/io.md#bio2-ldj-sub-io)
* Drop of SD mode support starting version 27
* Supporting 120 hz monitors starting version 27
* Many new LCD monitor variants appear with every new version
* 42" 120 hz for lightning cabinets starting version 27
* 42" 60 hz for non-lightning cabinets starting version 25
### 5th gen PC: RESIDENT (30) to EPOLIS (31)
* All prior cabinet configurations can be upgraded with a PCB and software upgrade
* [C300-xonarae](https://github.com/shizmob/arcade-docs/blob/main/konami/boards.md#c300-xonarae)
* Game engine supports FHD mode (1080p)
## Threading model and core responsibilities in PC-based games
Since the early days of 9th Style to today (as of time of writing this: EPOLIS), the threading model
hasn't changed significantly:
* Main and rendering thread
* Runs your typical D3D9 render loop
* Using D3D9ex starting version 27
* Starting and managing other threads
* Any file and game asset loading
* Handles all the core game logic of the different screens starting from the initial boot screen
to the core game-play screen
* IO thread
* Polls the main IO hardware and synchronizes the in-memory input and output state with the
hardware
* Executes commands issued by the main thread to the IO board such as dongle or card reader
commands (ezusb generation of IO only)
* Card reader thread (not applicable to versions 9 to 12)
* Runs the protocol to read/write the hardware of the readers
* Async execution of higher level commands issued by the main thread to the card reader hardware,
e.g. card read, card eject etc.
* Audio thread
* Streaming of audio data to the sound API
* DirectSound for versions 9 to 26
* WASAPI for versions 27 to 30 for non-lighting cabinets with ADE-6291 hardware
* ASIO for versions 27 and newer for lighting cabinets
* ASIO for version 30/31 and newer for non-lighting cabinets with C300-xonarae hardware
* Async execution of higher level commands issued by the main thread to the audio backend, e.g.
play audio, stop audio, etc.
* Network thread
* Network plumbing with the xrpc protocol
* Async execution of request-response commands issued by the main thread
## Main and rendering thread
With the game having transitioning to different screens throughout it's lifecycle, the main render
loop might contain different logic such as asset loading. The following focuses on the main
game-play screen, only. Common rendering logic still applies to other screens.
This follows your typical D3D9 single threaded rendering loop which boils down to the following:
* Begin the scene (`BeginScene`)
* Set the render target (`SetRenderTarget`)
* Clear the back buffer (`Clear`)
* Run engine step. This includes and is mixed with
* IO input evaluation
* Game engine state and (re-) drawing the scene
* Commands to the audio playback, e.g. play key sounds
* Setting IO outputs
* End the scene (`EndScene`)
* Target a minimum frame time
* Introduced with version 11
* Sleep (`Sleep` or `SleepEx`) to fill up the frame up to either 13 ms or 14 ms (depending on the
version)
* This was likely introduced to not have the game run at hundreds of FPS if v-sync was disabled
(probably when running in window mode for development/testing purposes)
* Swapping the back buffers (`Present`)
* D3D9 is configured with v-sync enabled by default and targets 60 hz
* With this configuration, the call to `Present` fills up the remaining frame time to target the
configured 60 hz refresh rate
### Rendering resolutions
The game engine went through a couple of different rendering resolutions:
* 640x240: version 1 to 8 (all twinkle hardware)
* 640x480: version 9 to 19 (1st and 2nd gen PC-based)
* 1280x720 (HD mode) and 640x480 (SD mode): version 20 to 27 (3rd and 4th gen PC-based)
* 1280x720 (HD mode) only for version 28 to 29 (4th gen PC-based)
* 1280x720 (HD mode) and 1920x1080 (FHD mode) for version 30 (4th gen PC-based)
* 1920x1080 (FHD mode) only for version 30+ (5th gen PC-based)
## Core engine timing and synchronization
The following outlines and explains the core engine concepts related to timing and synchronization.
### The origins, twinkle hardware
* It appears that the game has been on the same codebase since it's inception.
* This can be reasoned by the following observations
* 9th style as the first PC-based game very buggy on initial release
* 9th style threading model very clunky with various thread settings showing they tried to
prioritize different processing on a single core CPU
* Coming from twinkle hardware that is a realtime system vs. a Windows XP system
* Fixed playstation 1 based hardware with a refresh rate of
[59.8260978565 hz](https://github.com/mamedev/mame/blob/bf9df04e005697788ae988ef5aea91a1878fd631/src/devices/video/psx.cpp#L435)
* No need to assume getting anything else if the resource budget per frame is not exceeded
* All sub-systems were driven synchronously to that fixed time step
* No need for the engine to synchronize audio during the song. When the song is started
correctly, it stayed sync throughout the song
* Observations and assumptions
* It appears the developers struggled a lot with the significant platform shift to PC as indicated
by various core engine improvements throughout the years still
* Switches of hardware generations further complicated the situation as these forced them to further
drift away from how the game engine was initially designed on the twinkle system
### Frame time/timing and engine step
* The game's engine step and timing is frame based
* The main render loop defines the minimum valid timing window for the game engine to be able to
evaluate
* 60 hz/fps = 16.667 ms (rounded to three decimal places)
* 120 hz/fps = 8.333 ms (rounded to three decimal places), only relevant for lightning cabinets with their 120 hz
screen/mode
* Depending on the GPU hardware and configuration, the GPU might drive the screen not exactly at
perfectly 60 hz/fps = 16.667 ms
* As outlined in the [main render loop](#main-and-rendering-thread), the `Present` call is the
key function call to determine the frame time for the game engine
* Just having v-sync enabled and telling D3D9 to **target** 60 hz, it still depends on how the GPU
driver is implemented and how the GPU driver's implementation of D3D9 executes on the `Present`
call
* This is primarily determined by how the GPU driver is operating and driving connected display
hardware
* The following factors can contribute to that either directly or indirectly
* Different monitor types analog vs. digital (CRT vs. LCD)
* Different monitor connections VGA vs. DVI/HDMI/DP
* Different GPU drivers
* Different GPU hardware and vendors
* Different GPU settings
### Monitor check screen
The monitor check screen was introduced with version 14. This was a solution to the problem of not
guaranteeing a single fixed refresh rate throughout different GPU and monitor combinations. See
a detailed explanation in the previous sub-subsection about
[what influences the frame time](#frame-timetiming-and-engine-step) of the game.
The goal of the monitor check is to measure the frame time of the main render loop and use the
results for [driving the core engine step](#engine-step-and-synchronization).
The monitor check evolved slightly as different GPU and monitor hardware, and GPU drivers yielded
varying refresh rates that determined the frame times of the main game loop.
Actual values are outlined further down in the [engine step time](#engine-step-time) section.
There are two main versions of the monitor check, all of them have always been part of the boot
process:
* 14
* Measures a total of 3000 frames
* If total time this took < 50004 ms -> so average of 16.668 ms per frame = 59.9952 hz
* S-Video mode -> 59.95 hz (also shows S-VIDEO when the monitor check completes)
* Otherwise VGA mode -> 60.05 hz
* If VGA is determined, the game patches the chart event data when loading
* `event_timestamp * 0.99817199 + 0.40000001`
* When S-Video no charts are patched and the timing data in the chart is used as is
* 15 to 18
* Identical to 14 except that chart patching now happens in milliseconds instead of frames
* VGA mode: `16.65279`
* S-Video mode: `16.680567`
* `event_timestamp * (1.0 / frame_time) + 0.40000001)`
* 19
* Identical to previous version
* Monitor check screen shows current FPS on the last revision of that version. However, it doesn't
use the value shown there by any means. Assuming this was added before the introduction of the
new monitor check on 20.
* 20 to 26
* Runs on boot or when switching monitor modes SD vs. HD
* Measures only 1200 frames
* Takes the average refresh rate of 1200 frames
* Applies the measured avg. frame time directly to the charts before song
* 27 to 30
* Frame rate measuring identical to prior versions
* Added additional logic after the frame time measurements for handling of 120 hz displays
* Includes checking the monitor and if the framerate matches as expected
* 30/31 LDJ-010 upgrade
* Added NvDisplayConfigLDJ tool which runs on system start and configures a custom timing in the
NVIDIA GPU driver to ensure a fixed monitor refresh rate
* 31
* Same code as before
* Consider the first 460 frames of the measurement as warm-up frames
* Discard these for the actual measurement to get more stable frame times
* Use a base avg. value of 119.982 for the 120 hz monitors and 59.9 for 60 hz monitors. Further
frames measured are counted towards the average with the given base value
### Engine core game-play with visual and audio synchronization
#### Chart data
* Chart data encodes note timing and timing window information
* Chart data consists of *note events* encoding a timestamp and note information such as type
and key-sound information
* Timing windows are defined per chart
* Most infamous example: GAMBOL (7Key/Another)
* Game engine timestamp evaluation and note event timestamp encoding
* 9 to 14: Refresh rate in hz
* 15 to 31: Milliseconds (equivalent to assuming 1000 fps)
* Fundamentally, that doesn't change game play experience as it's just a different way of
evaluating the timestamps since refresh rate in hz/frame rate in fps can be converted lossless to
frame time in ms
#### Engine step time
The engine uses the following source for frame rate/time to drive internal logic on the following
versions
* 9 to 13: Hardcoded 59.95 hz
* 14: Either 59.95 hz or 60.05 hz determined by which value is determined to be closer to the
measured one during the monitor check screen on startup
* 15 to 19: 59.95 hz or 60.05 hz
* Monitor check on startup measures the frame time and picks the value closest to what's been
measured
* Monitor check result can be overridden with the *Output Type* setting in the operator menu
* *S-Video* to force to 59.95 hz
* *VGA* to force to 60.05 hz
* 20 to 31: Monitor check on boot determines the frame time and uses the result throughout the
entire game session
#### Engine step and synchronization
Per frame engine step advancing and synchronization during game-play
* Game-play needs synchronization of the following aspects
* Drawn content on the screen
* Background audio playback track
* Key sound effects
* The game engine synchronizes these only at the start of a song
* It takes known/determined refresh rate/frame time as the fixed time for every frame cycle
throughout the entire song
* It starts playback of the background audio track together with playback of the chart data
* With every engine step/frame it advances internal calculations by that fixed amount of time.
Thus, the game engine expects this to be constant/stable throughout an entire song
* The chart data is advanced every frame by the engine
* Key sound events are turned into audio playback on command as the chart advances
* No re-synchronization or check-pointing between main rendering thread and audio is happening
throughout the song
* Remark: The above does not consider any kind of offsetting and timing adjustments for the sake
of keeping this simple and focus on the absolute core concepts

View File

@@ -48,6 +48,8 @@ Available implementations that can be swapped out depending on which kind of IO
use: use:
- `iidxio`: Default implementation supporting keyboard, mouse and USB game controllers - `iidxio`: Default implementation supporting keyboard, mouse and USB game controllers
- [iidxio-async](iidxhook/iidxio-async.md): Shim implementation that runs another iidxio implementation in a dedicated
thread
- [iidxio-bio2](iidxhook/iidxio-bio2.md): Support BIO2 hardware - [iidxio-bio2](iidxhook/iidxio-bio2.md): Support BIO2 hardware
- [iidxio-ezusb](iidxhook/iidxio-ezusb.md): Support C02 ezusb FX hardware - [iidxio-ezusb](iidxhook/iidxio-ezusb.md): Support C02 ezusb FX hardware
- [iidxio-ezusb2](iidxhook/iidxio-ezusb2.md): Support IO2 ezusb FX2 hardware - [iidxio-ezusb2](iidxhook/iidxio-ezusb2.md): Support IO2 ezusb FX2 hardware

View File

@@ -0,0 +1,224 @@
# IIDX "Syncbook": A guide to ensuring sync and performant gameplay
This is a guide applicable to all IIDX versions that are native Windows PC-based. The goal is to
enable proper configuration of those games to ensure the game engine "runs in-sync" with any of its
IO (visual GPU/display output, audio output, user input) resulting in high and stable performance
for smooth game-play.
This document won't go into the implementation details of the game engine. Please refer to the
[IIDX engine details journal](../dev/journal/2025-02-09-iidx-engine.md) for a more in-depth
information.
## Understanding the problems and options to address them
First, let's understand what the key problems are and how they contribute to different issues
that impact game-play.
### Song de-syncing
Symptom: Throughout playing a song, the audio is de-syncing even it was fine when the song started.
Cause: The game engine is fundamentally designed to run on a fixed and consistent frame
rate/time per engine step. A mismatch of expected frame time by the game engine and actually delivered
frame time by the GPU driver. This can come either as a stable frame time that just mismatches in
general or (highly) fluctuating frame times.
* G-sync on modern displays causes known fluctuations because it adjusts dynamically the monitor
refresh rate
* V-sync not correctly configured/enforced or even vsync-off override in driver is causing
inconsistent frame times
* Incorrect display timings causing refresh rate fluctuations resulting in inconsistent frame times
Stable frame times but not having the correct ones that the game engine expects is a different
problem that can be addressed by:
* Knowing the refresh rates expected by the game engine of the different game versions
* Configuring your GPU driver's display timings to match the expected frame times
* Or, patch the game's chart data with your custom display timings so the game engine gets uses
*your* "correct" frame times
* Note: Offline patching the chart data doesn't work for several game versions as the monitor
check does override this data, but not as flexible as required
* Use the chart patch feature of bemanitools instead
### Micro-stuttering and non-smooth note scrolling
This is a trickier problem as it can be caused by a few different things.
* GPU related
* Fluctuating refresh rates result in fluctuating frame times in the main game loop
* GPU power configuration in non-performance mode (e.g. "power saving") causes processing latency
due to sleep states
* Display related
* Display firmware buggy and/or internal scalers that expect to run at very specific refresh rates
and cannot adapt to any custom display timings enforced by the GPU
* A known example is the official
[PENDUAL LCD monitor](https://github.com/shizmob/arcade-docs/blob/6ac99975cdb2bf668362f65fa9fa3ffb2127308b/konami/product/GULDJ-JI.md#notes-and-known-issues) that does not v-sync correctly to any other refresh-rate than 60.000 hz
* CPU related
* CPU power configuration on Windows in non-performance mode (e.g. "power saving") causes
processing latency due to sleep states
* Correct CPU C-states configuration in BIOS/UEFI
* These cannot be configured in Windows and are separate from Windows's power configuration
* Other stuff running in the background of the system causing fluctuations
* (Synchronous) Disk I/O heavy applications stealing CPU time
* Or any other process creating a considerable amount of CPU or GPU load
## Configuration guide for different game versions
### Measuring monitor refresh rate
Let's start with configuring the system to meet the game engine's expectation regarding the
target monitor refresh rate and requiring vsync.
First, use the [d3d9-monitor-check tool](../tools/d3d9-monitor-check.md) to measure the currently
configured refresh rate of your monitor. Note that your monitor might yield different timings on
different resolutions and different game versions run on
[different rendering resolutions](../dev/journal/2025-02-09-iidx-engine.md#rendering-resolutions).
For example, the game version is 31 with the rendering resolution of 1920x1080 in FHD mode that you
want to target:
```bat
d3d9-monitor-check.exe cmdline refresh-rate-test 1920 1080 60
```
The test shows the current monitor refresh rate and the average refresh rate over the course of
the test. Check that the avg. refresh rate is stable during the measuring phase (during warm-up,
it's ok if it fluctuates).
This test allows you to determine/check:
* Refresh rate/frame time fluctuations: if you see (high) fluctuations on the first or second
decimal place
* What's your current target refresh rate the GPU is driving your monitor at
* If vsync isn't overridden by some other driver setting as you want to see a refresh rate around
the 60 hz mark
### Measuring vsync issues
Some displays or the GPU configuration might lead to vsync issues which can be detected with the
`d3d9-monitor-check.exe` tool as well.
```bat
d3d9-monitor-check.exe cmdline vsync-test 1920 1080 60
```
This runs a test with a VSYNC text that alternates red and cyan colors. If the text appears grey
all the time, everything's fine. If you spot brief red or cyan text either occasionally or
periodically, your current configuration has vsync issues resulting in skipped frames or old
frames displaying longer.
### Configuration
The following are recommended configurations for the different game versions. If any of these
don't work as expected, you have to troubleshoot and tweak these potentially. Please refer to the
[guidelines above](#configuration-guide-for-different-game-versions) to understand how to use
the tooling and test your changes.
#### Recommended configuration with NVIDIA GPU and driver
We want to achieve the following configuration on the GPU driver:
* Turn-off g-sync if you have a monitor that supports it
* Disable power saving mode on GPU driver
* V-sync is not forced off
* Run the display on a target refresh rate of `59.950 hz` which has been determined to be
[the most compatible across all PC-based versions](../dev/journal/2025-02-09-iidx-engine.md#engine-step-time).
##### Turn-off g-sync
Create a new GPU profile for IIDX, if it doesn't exist yet:
```bat
nvgpu.exe profile create iidx
```
Add the application names when the profile needs to be applied:
```bat
:: For iidx versions 9 to 17
nvgpu.exe profile application-add iidx bm2dx.exe
:: For iidx versions 18+
nvgpu.exe profile application-add iidx launcher.exe
```
Disable G-SYNC for the profile:
```bat
nvgpu.exe profile gsync-disable iidx
```
##### Disable power saving mode
Set GPU power state to maximum for the profile (assumes you have a
[GPU profile called `iidx` already created](#turn-off-g-sync)):
```bat
nvgpu.exe profile gpu-power-state-max iidx
```
##### Configure and verify target refresh rate of 59.950 hz and vsync
Get display ID of your primary display:
```bat
nvgpu.exe display primary-display-id
```
Copy the hex-value of the display ID and use it in the following commands.
Test the custom display timing first, e.g. for versions that run in 1920x1080
(Replace `<DISPLAY_ID> ` with the primary display ID you got):
```bat
nvgpu.exe display custom-resolution-test <DISPLAY_ID> 1920 1080 59.95 10
```
This will test it for 10 seconds and then revert. If the result looked good, i.e. the screen didn't
go blank or the display output was garbage, apply it:
```bat
nvgpu.exe display custom-resolution-set <DISPLAY_ID> 1920 1080 59.95
```
Test and verify the configuration is applied and works correctly:
```bat
d3d9-monitor-check.exe cmdline refresh-rate-test 1920 1080 60
```
Test if the enforced refresh rate is compatible with your display and vsync is working correctly:
```bat
d3d9-monitor-check.exe cmdline vsync-test 1920 1080 60
```
##### Alternative refresh rate configuration
If for some reason your display doesn't support 59.950 hz properly, i.e. display artifacts or vsync
issues, you can use any other 60 hz compatible refresh rate, e.g. anything between 59.900 hz and
60.100 hz that your display supports properly.
Follow the same steps [as above](#configure-and-verify-target-refresh-rate-of-59950-hz-and-vsync)
but use a different refresh rate, e.g. 60.000 hz.
Verify using the `d3d9-monitor-check.exe` with the outlined steps if you need to play around to find
a refresh rate that works for your setup.
For the game versions 9 to 19, you have to use the chart patch feature of bemanitools to patch
the charts to your custom refresh rate. Otherwise, the game engine will run on your configured
refresh rate, but it will take the non-matching refresh rate from the chart data which causes
song de-syncing.
For example, to configure a refresh rate of 60.000 hz in the iidxhook config file:
```text
gfx.monitor_check=60.000
```
##### ATI/AMD
Currently, there is no tooling provided by bemanitools to configure the AMD GPU driver. The basic
concepts of what needs to be configured still applies as outlined in the NVIDIA sections above
though, e.g. through AMD's GPU control panel.
Further steps and instructions TBD

View File

@@ -146,16 +146,7 @@ This can be related to various issues:
start "" /relatime "gamestart.bat" start "" /relatime "gamestart.bat"
``` ```
- Enforce v-sync enabled in your GPU settings. Also refer to the [iidx-syncbook](iidx-syncbook.md).
- Ensure that you have a constant refresh rate around the 60 hz (59.9xx or 60.0xx) that is not
jumping around. Use the timebase feature of one of the newer games to check that or enable
iidxhook's timebase and check the log output for the determined value. Run this a few times and
check if the results differ.
- Use iidxhook's frame rate limiter feature (see further below) to software lock the refresh rate.
This might be necessary on Windows 7 and newer for D3D8 games, e.g. iidx 9 to 12, which seem to
ignore GPU side v-sync.
- Use iidxhook's auto timebase feature (see further below) or set a pre-determined value to cut down
start-up times.
### The game still stutters (randomly) and drifts off-sync ### The game still stutters (randomly) and drifts off-sync
@@ -173,9 +164,7 @@ This can be caused by:
## My songs are offsync ## My songs are offsync
- Make sure your machine's refresh rate is stable Refer to the [iidx-syncbook](iidx-syncbook.md).
- If you don't get a close to 59.94hz refresh rate, use the software monitor check/auto timebase
that's built into iidxhook (refer to help/config file)
## The game crashes instantly (10th, RED, HAPPY SKY) ## The game crashes instantly (10th, RED, HAPPY SKY)
@@ -233,6 +222,8 @@ file) or use a CLVSD.ax codec which has the debugger checks removed.
## I used the auto timebase option and/or limited my refresh rate but the songs are still going offsync ## I used the auto timebase option and/or limited my refresh rate but the songs are still going offsync
Refer to the [iidx-syncbook](iidx-syncbook.md) if you haven't already.
There aren't many options left. The old games were developed for specific hardware and are not There aren't many options left. The old games were developed for specific hardware and are not
guaranteed to work well on (especially) newer hardware. Multiple monitor setups can also have a bad guaranteed to work well on (especially) newer hardware. Multiple monitor setups can also have a bad
impact on a stable refresh rate. Try a setup with just a single monitor you want to use for gameplay impact on a stable refresh rate. Try a setup with just a single monitor you want to use for gameplay

View File

@@ -115,16 +115,7 @@ This can be related to various issues:
start "" /relatime "gamestart.bat" start "" /relatime "gamestart.bat"
``` ```
- Enforce v-sync enabled in your GPU settings. Also refer to the [iidx-syncbook](iidx-syncbook.md).
- Ensure that you have a constant refresh rate around the 60 hz (59.9xx or 60.0xx) that is not
jumping around. Use the timebase feature of one of the newer games to check that or enable
iidxhook's timebase and check the log output for the determined value. Run this a few times and
check if the results differ.
- Use iidxhook's frame rate limiter feature (see further below) to software lock the refresh rate.
This might be necessary on Windows 7 and newer for D3D8 games, e.g. iidx 9 to 12, which seem to
ignore GPU side v-sync.
- Use iidxhook's auto timebase feature (see further below) or set a pre-determined value to cut down
start-up times.
### The game still stutters (randomly) and drifts off-sync ### The game still stutters (randomly) and drifts off-sync
@@ -142,9 +133,7 @@ This can be caused by:
## My songs are offsync ## My songs are offsync
- Make sure your machine's refresh rate is stable Refer to the [iidx-syncbook](iidx-syncbook.md).
- If you don't get a close to 59.94hz refresh rate, use the software monitor check/auto timebase
that's built into iidxhook (refer to help/config file)
## The game crashes instantly ## The game crashes instantly
@@ -192,6 +181,8 @@ CLVSD.ax codec which has the debugger checks removed.
## I used the auto timebase option and/or limited my refresh rate but the songs are still going offsync ## I used the auto timebase option and/or limited my refresh rate but the songs are still going offsync
Refer to the [iidx-syncbook](iidx-syncbook.md) if you haven't already.
There aren't many options left. The old games were developed for specific hardware and are not There aren't many options left. The old games were developed for specific hardware and are not
guaranteed to work well on (especially) newer hardware. Multiple monitor setups can also have a bad guaranteed to work well on (especially) newer hardware. Multiple monitor setups can also have a bad
impact on a stable refresh rate. Try a setup with just a single monitor you want to use for gameplay impact on a stable refresh rate. Try a setup with just a single monitor you want to use for gameplay

View File

@@ -132,16 +132,7 @@ This can be related to various issues:
start "" /relatime "gamestart.bat" start "" /relatime "gamestart.bat"
``` ```
- Enforce v-sync enabled in your GPU settings. Also refer to the [iidx-syncbook](iidx-syncbook.md).
- Ensure that you have a constant refresh rate around the 60 hz (59.9xx or 60.0xx) that is not
jumping around. Use the timebase feature of one of the newer games to check that or enable
iidxhook's timebase and check the log output for the determined value. Run this a few times and
check if the results differ.
- Use iidxhook's frame rate limiter feature (see further below) to software lock the refresh rate.
This might be necessary on Windows 7 and newer for D3D8 games, e.g. iidx 9 to 12, which seem to
ignore GPU side v-sync.
- Use iidxhook's auto timebase feature (see further below) or set a pre-determined value to cut down
start-up times.
## "NETWORK WARNING" instead of "NETWORK OK" ## "NETWORK WARNING" instead of "NETWORK OK"
@@ -154,15 +145,7 @@ This can be caused by:
## My songs are offsync ## My songs are offsync
The built-in monitor check just determines if the game should sync to either 59.94 hz (S-Video Refer to the [iidx-syncbook](iidx-syncbook.md).
setting) or 60.04 hz (VGA setting). If you don't have a setup that runs on (as close as possible)
these values:
- Make sure your machine's refresh rate is stable, e.g. 60.00x hz.
- If you don't get a close to 59.94hz (S-Video setting) or 60.04 hz (VGA setting) refresh rate, go
an set the output mode in the operator menu to "VGA" to enforce the game to run chart syncing on
60.04 hz refresh rate (even if your setup does not have that value). Next, use the software
monitor check/auto timebase that's built into iidxhook (refer to cmd help/configfile).
## My game runs too fast ## My game runs too fast
@@ -205,6 +188,8 @@ CLVSD.ax codec which has the debugger checks removed.
## I used the auto timebase option and/or limited my refresh rate but the songs are still going offsync ## I used the auto timebase option and/or limited my refresh rate but the songs are still going offsync
Refer to the [iidx-syncbook](iidx-syncbook.md) if you haven't already.
There aren't many options left. The old games were developed for specific hardware and are not There aren't many options left. The old games were developed for specific hardware and are not
guaranteed to work well on (especially) newer hardware. Multiple monitor setups can also have a bad guaranteed to work well on (especially) newer hardware. Multiple monitor setups can also have a bad
impact on a stable refresh rate. Try a setup with just a single monitor you want to use for gameplay impact on a stable refresh rate. Try a setup with just a single monitor you want to use for gameplay

View File

@@ -143,16 +143,7 @@ This can be related to various issues:
start "" /relatime "gamestart.bat" start "" /relatime "gamestart.bat"
``` ```
- Enforce v-sync enabled in your GPU settings. Also refer to the [iidx-syncbook](iidx-syncbook.md).
- Ensure that you have a constant refresh rate around the 60 hz (59.9xx or 60.0xx) that is not
jumping around. Use the timebase feature of one of the newer games to check that or enable
iidxhook's timebase and check the log output for the determined value. Run this a few times and
check if the results differ.
- Use iidxhook's frame rate limiter feature (see further below) to software lock the refresh rate.
This might be necessary on Windows 7 and newer for D3D8 games, e.g. iidx 9 to 12, which seem to
ignore GPU side v-sync.
- Use iidxhook's auto timebase feature (see further below) or set a pre-determined value to cut down
start-up times.
## "NETWORK WARNING" instead of "NETWORK OK" ## "NETWORK WARNING" instead of "NETWORK OK"
@@ -165,15 +156,7 @@ This can be caused by:
## My songs are offsync ## My songs are offsync
The built-in monitor check just determines if the game should sync to either 59.94 hz (S-Video Refer to the [iidx-syncbook](iidx-syncbook.md).
setting) or 60.04 hz (VGA setting). If you don't have a setup that runs on (as close as possible)
these values:
- Make sure your machine's refresh rate is stable, e.g. 60.00x hz.
- If you don't get a close to 59.94hz (S-Video setting) or 60.04 hz (VGA setting) refresh rate, go
an set the output mode in the operator menu to "VGA" to enforce the game to run chart syncing on
60.04 hz refresh rate (even if your setup does not have that value). Next, use the software
monitor check/auto timebase that's built into iidxhook (refer to cmd help/configfile).
## My game runs too fast ## My game runs too fast
@@ -211,6 +194,8 @@ CLVSD.ax codec which has the debugger checks removed.
## I used the auto timebase option and/or limited my refresh rate but the songs are still going offsync ## I used the auto timebase option and/or limited my refresh rate but the songs are still going offsync
Refer to the [iidx-syncbook](iidx-syncbook.md) if you haven't already.
There aren't many options left. The old games were developed for specific hardware and are not There aren't many options left. The old games were developed for specific hardware and are not
guaranteed to work well on (especially) newer hardware. Multiple monitor setups can also have a bad guaranteed to work well on (especially) newer hardware. Multiple monitor setups can also have a bad
impact on a stable refresh rate. Try a setup with just a single monitor you want to use for gameplay impact on a stable refresh rate. Try a setup with just a single monitor you want to use for gameplay

View File

@@ -143,16 +143,7 @@ This can be related to various issues:
start "" /relatime "gamestart.bat" start "" /relatime "gamestart.bat"
``` ```
- Enforce v-sync enabled in your GPU settings. Also refer to the [iidx-syncbook](iidx-syncbook.md).
- Ensure that you have a constant refresh rate around the 60 hz (59.9xx or 60.0xx) that is not
jumping around. Use the timebase feature of one of the newer games to check that or enable
iidxhook's timebase and check the log output for the determined value. Run this a few times and
check if the results differ.
- Use iidxhook's frame rate limiter feature (see further below) to software lock the refresh rate.
This might be necessary on Windows 7 and newer for D3D8 games, e.g. iidx 9 to 12, which seem to
ignore GPU side v-sync.
- Use iidxhook's auto timebase feature (see further below) or set a pre-determined value to cut down
start-up times.
## "NETWORK WARNING" instead of "NETWORK OK" ## "NETWORK WARNING" instead of "NETWORK OK"
@@ -165,11 +156,7 @@ This can be caused by:
## My songs are offsync ## My songs are offsync
From this version onwards (if you use the very final data of Lincle), the game comes with a built-in Refer to the [iidx-syncbook](iidx-syncbook.md).
auto timebase option ("monitor check" on startup) which dynamically, detects the refresh rate of
your current setup. Thus, BT5's timebase option is not included from this hook version onwards,
anymore. Ensure that refresh rate displayed is very stable, e.g. 60.00x hz, and the game should be
able to provide you with a smooth and sync game experience.
## My game runs too fast ## My game runs too fast

View File

@@ -155,11 +155,7 @@ This can be related to various issues:
start "" /relatime "gamestart.bat" start "" /relatime "gamestart.bat"
``` ```
- Enforce v-sync enabled in your GPU settings. Also refer to the [iidx-syncbook](iidx-syncbook.md).
- Ensure that you have a constant refresh rate around the 60 hz (59.9xx or 60.0xx) that is not
jumping around. Use the timebase feature of one of the newer games to check that or enable
iidxhook's timebase and check the log output for the determined value. Run this a few times and
check if the results differ.
## "NETWORK WARNING" instead of "NETWORK OK" ## "NETWORK WARNING" instead of "NETWORK OK"
@@ -172,11 +168,7 @@ This can be caused by:
## My songs are offsync ## My songs are offsync
From this version onwards (or Lincle very final revision), the game comes with a built-in auto Refer to the [iidx-syncbook](iidx-syncbook.md).
timebase option ("monitor check" on startup) which dynamically, detects the refresh rate of your
current setup. Thus, BT5's timebase option is not included from this hook version onwards, anymore.
Ensure that refresh rate displayed is very stable, e.g. 60.00x hz, and the game should be able to
provide you with a smooth and sync game experience.
## My game runs too fast ## My game runs too fast

View File

@@ -159,11 +159,7 @@ This can be related to various issues:
start "" /relatime "gamestart.bat" start "" /relatime "gamestart.bat"
``` ```
- Enforce v-sync enabled in your GPU settings. Also refer to the [iidx-syncbook](iidx-syncbook.md).
- Ensure that you have a constant refresh rate around the 60 hz (59.9xx or 60.0xx) that is not
jumping around. Use the timebase feature of one of the newer games to check that or enable
iidxhook's timebase and check the log output for the determined value. Run this a few times and
check if the results differ.
## "NETWORK WARNING" instead of "NETWORK OK" ## "NETWORK WARNING" instead of "NETWORK OK"
@@ -176,11 +172,7 @@ This can be caused by:
## My songs are offsync ## My songs are offsync
From IIDX 20 (or Lincle very final revision) onwards, the game comes with a built-in auto timebase Refer to the [iidx-syncbook](iidx-syncbook.md).
option ("monitor check" on startup) which dynamically, detects the refresh rate of your current
setup. Thus, BT5's timebase option is not included from this hook version onwards, anymore. Ensure
that refresh rate displayed is very stable, e.g. 60.00x hz, and the game should be able to provide
you with a smooth and sync game experience.
## My game runs too fast ## My game runs too fast

View File

@@ -158,11 +158,7 @@ This can be related to various issues:
start "" /relatime "gamestart.bat" start "" /relatime "gamestart.bat"
``` ```
- Enforce v-sync enabled in your GPU settings. Also refer to the [iidx-syncbook](iidx-syncbook.md).
- Ensure that you have a constant refresh rate around the 60 hz (59.9xx or 60.0xx) that is not
jumping around. Use the timebase feature of one of the newer games to check that or enable
iidxhook's timebase and check the log output for the determined value. Run this a few times and
check if the results differ.
## "NETWORK WARNING" instead of "NETWORK OK" ## "NETWORK WARNING" instead of "NETWORK OK"
@@ -175,11 +171,7 @@ This can be caused by:
## My songs are offsync ## My songs are offsync
From IIDX 20 (or Lincle very final revision) onwards, the game comes with a built-in auto timebase Refer to the [iidx-syncbook](iidx-syncbook.md).
option ("monitor check" on startup) which dynamically, detects the refresh rate of your current
setup. Thus, BT5's timebase option is not included from this hook version onwards, anymore. Ensure
that refresh rate displayed is very stable, e.g. 60.00x hz, and the game should be able to provide
you with a smooth and sync game experience.
## My game runs too fast ## My game runs too fast

View File

@@ -6,6 +6,7 @@ The following games are compatible with this version of iidxhook:
- BISTROVER - BISTROVER
- CASTHOUR - CASTHOUR
- RESIDENT - RESIDENT
- EPOLIS
The games must be bootstrapped using [launcher](../launcher.md). The games must be bootstrapped using [launcher](../launcher.md).
@@ -57,7 +58,7 @@ unpacked data looks like this:
- Unpack the package containing iidxhook9 into the root folder so iidxhook9.dll and all other - Unpack the package containing iidxhook9 into the root folder so iidxhook9.dll and all other
files are located in the same folder as *data*, *prop*, *bm2dx.dll*, etc. files are located in the same folder as *data*, *prop*, *bm2dx.dll*, etc.
- For version 30 - For version 30-31
- Unpack the package containing iidxhook9 into the `modules` folder so iidxhook9.dll and all other - Unpack the package containing iidxhook9 into the `modules` folder so iidxhook9.dll and all other
files are located in the same folder as the game's DLLs, e.g. *bm2dx.dll*, etc. files are located in the same folder as the game's DLLs, e.g. *bm2dx.dll*, etc.
@@ -93,6 +94,12 @@ The syntax for the "key=value" is the same as in the config file. Make sure to h
However, if a parameter is specifed in the configuration file and as a command line argument, the However, if a parameter is specifed in the configuration file and as a command line argument, the
command line argument overrides the config file's value. command line argument overrides the config file's value.
# Note on camhook
The cammera hook (camhook) is used to allow other class compliant cameras to be used. Depending on the variant of the game, you will need to select the correct camera port layout.
For original LDJ, this is always 0, for conversion kit LDJ and original TDJ-JA, this is 1, and for TDJ-JB this will be 2 (this case is rare / you will know if this is needed on your setup).
# Eamuse network setup # Eamuse network setup
If you want to run the games online, you need a valid PCBID and the service URL. Open If you want to run the games online, you need a valid PCBID and the service URL. Open
@@ -205,11 +212,7 @@ This can be related to various issues:
start "" /relatime "gamestart.bat" start "" /relatime "gamestart.bat"
``` ```
- Enforce v-sync enabled in your GPU settings. Also refer to the [iidx-syncbook](iidx-syncbook.md).
- Ensure that you have a constant refresh rate around the 60 hz (59.9xx or 60.0xx) that is not
jumping around. Use the timebase feature of one of the newer games to check that or enable
iidxhook's timebase and check the log output for the determined value. Run this a few times and
check if the results differ.
## "NETWORK WARNING" instead of "NETWORK OK" ## "NETWORK WARNING" instead of "NETWORK OK"
@@ -222,11 +225,7 @@ This can be caused by:
## My songs are offsync ## My songs are offsync
From IIDX 20 (or Lincle very final revision) onwards, the game comes with a built-in auto timebase Refer to the [iidx-syncbook](iidx-syncbook.md).
option ("monitor check" on startup) which dynamically, detects the refresh rate of your current
setup. Thus, BT5's timebase option is not included from this hook version onwards, anymore. Ensure
that refresh rate displayed is very stable, e.g. 60.00x hz, and the game should be able to provide
you with a smooth and sync game experience.
## My game runs too fast ## My game runs too fast

View File

@@ -0,0 +1,22 @@
# IIDXIO async API implementation
This implementation of the iidxio API is a shim library that takes another iidxio library and
runs the functions `iidx_io_ep1_send`, `iidx_io_ep2_recv` and `iidx_io_ep3_write_16seg` in a
dedicated thread. State synchronization to the getter and setter functions is also handled
transparently.
Usage of this **may** improve performance of certain iidxio implementations or when using them
in certain integrations, e.g. the send and receive functions of a iidxio implementation for some
target IO hardware calls are synchronous and expensive.
This is not a fix/solution to a badly implemented iidxio library with poor performance as it cannot
make it go faster and address potential latency issues, for example.
Use with caution and know why and when you need to use it.
## Setup
* Add `iidxio-async.dll` in the same folder as your `iidxhookX.dll`
* Rename your `iidxio.dll` to `iidxio-async-child.dll`
* Rename `iidxio-async.dll` to `iidxio.dll`
* Run the game

View File

@@ -0,0 +1,28 @@
# D3D9 Monitor Check
A separate application providing various music game relevant tests, e.g. the infamous IIDX “monitor
check” without having to run the actual game. The tool can be used to debug and test your monitor
regarding refresh rate calibration (custom monitor timings), v-sync issues or ghosting issues.
Simply run the tool without any arguments to get a full synopsis with usage instructions.
## "Accuracy" remarks refresh rate test/monitor check
The tool has been tested on an actual cabinet with `nvgpu` setting different custom timings. The
accuracy seems to be even higher than what IIDXs monitor check is actually showing. For example,
with a custom timing of 59.900 hz, this tool yields fairly accurate and stable avg. 59.902 hz.
The monitor check of IIDX 29 showed results of 59.8981 hz to 59.8997 hz on screen. As these are the
only visible values to the user, determining a specific (avg.) value that can be used as input for
other tooling or settings (e.g. patching charts to a different refresh rate on older games with
bemanitools) is difficult. This doesn't mean that the game's monitor checks are actually
inaccurate or wrong. Once the check is finished it uses the
[avg. value it determined](../dev/journal/2025-02-09-iidx-engine.md) to patch the chart data
correctly. The value displayed to the user is just the floating value.
Thus, modern games with a built-in monitor check (starting IIDX 20) are syncing up
fine and don't need any further patching or modifications.
For older games, picking a value that is not as close as possible to an accurate avg. value can
easily lead to issues with sync. So it's recommended to use the d3d9-monitor-check tool to get the
most accurate value.

25
doc/tools/nvgpu.md Normal file
View File

@@ -0,0 +1,25 @@
# nvgpu - Command line tool to configure and tweak the NVIDIA GPU driver
An open source re-implementation of the “NvDisplayConfigLDJ" tool with additional enhancements.
The tool is based on NVIDIA's [nvapi](https://github.com/NVIDIA/nvapi) which is an interface to
various driver settings that can also be tweaked from the NVIDIA Control Panel. The goal of this
tool is to provide a streamlined command line interface to configure various settings that can
improve gameplay experience significantly.
This can be used to tweak your nvidia GPU driver settings to create custom display timings to address
IIDXs requirement if expecting proper display timings. This can also be used for any legacy IIDX
versions that even expect very specific display timings, e.g. 59.95 or 60.05 hz.
Furthermore, creating application profiles allows further tweaks to important GPU settings such as
the current performance mode setting. This is crucial to ensure the GPU is not going into any kind of
power saving states which results in non-smooth scrolling during gameplay and micro stuttering that
cannot be measured on application level.
Simply run the tool without any arguments to get a full synopsis of available commands.
## Example usage for IIDX
Refer to the dedicated [iidx-syncbook](../iidxhook/iidx-syncbook.md) documentation for details on
how to use `nvgpu` to configure your system to run IIDX versions with proper display timings, smooth
frame rates and sync game-play.

View File

@@ -1,31 +0,0 @@
#ifndef BEMANITOOLS_API_THREAD_H
#define BEMANITOOLS_API_THREAD_H
#include <stdint.h>
#ifdef __GNUC__
/* Bemanitools is compiled with GCC (MinGW, specifically) as of version 5 */
#define LOG_CHECK_FMT __attribute__((format(printf, 2, 3)))
#else
/* Compile it out for MSVC plebs */
#define LOG_CHECK_FMT
#endif
/* An AVS-style logger function. Comes in four flavors: misc, info, warning,
and fatal, with increasing severity. Fatal loggers do not return, they
abort the running process after writing their message to the log.
"module" is an arbitrary short string identifying the source of the log
message. The name of the calling DLL is a good default choice for this
string, although you might want to identify a module within your DLL here
instead.
"fmt" is a printf-style format string. Depending on the context in which
your DLL is running you might end up calling a logger function exported
from libavs, which has its own printf implementation (including a number of
proprietary extensions), so don't use any overly exotic formats. */
typedef void (*btapi_log_formatter_t)(const char *module, const char *fmt, ...)
LOG_CHECK_FMT;
#endif

View File

@@ -1,20 +0,0 @@
#ifndef BEMANITOOLS_API_THREAD_H
#define BEMANITOOLS_API_THREAD_H
#include <stdint.h>
/* An API for spawning threads. This API is defined by libavs, although
Bemanitools itself may supply compatible implementations of these functions
to your DLL, depending on the context in which it runs.
NOTE: You may only use the logging functions from a thread where Bemanitools
calls you, or a thread that you create using this API. Failure to observe
this restriction will cause the process to crash. This is a limitation of
libavs itself, not Bemanitools. */
typedef int (*btapi_thread_create_t)(
int (*proc)(void *), void *ctx, uint32_t stack_sz, unsigned int priority);
typedef void (*btapi_thread_join_t)(int thread_id, int *result);
typedef void (*btapi_thread_destroy_t)(int thread_id);
#endif

View File

@@ -0,0 +1,947 @@
/*********************************************************************************************************\
|* *|
|* SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. *|
|* SPDX-License-Identifier: MIT *|
|* *|
|* 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 "NvApiDriverSettings.h"
EValues_OGL_AA_LINE_GAMMA g_valuesOGL_AA_LINE_GAMMA[OGL_AA_LINE_GAMMA_NUM_VALUES] =
{
OGL_AA_LINE_GAMMA_DISABLED,
OGL_AA_LINE_GAMMA_ENABLED,
OGL_AA_LINE_GAMMA_MIN,
OGL_AA_LINE_GAMMA_MAX,
};
EValues_OGL_CPL_GDI_COMPATIBILITY g_valuesOGL_CPL_GDI_COMPATIBILITY[OGL_CPL_GDI_COMPATIBILITY_NUM_VALUES] =
{
OGL_CPL_GDI_COMPATIBILITY_PREFER_DISABLED,
OGL_CPL_GDI_COMPATIBILITY_PREFER_ENABLED,
OGL_CPL_GDI_COMPATIBILITY_AUTO,
};
EValues_OGL_CPL_PREFER_DXPRESENT g_valuesOGL_CPL_PREFER_DXPRESENT[OGL_CPL_PREFER_DXPRESENT_NUM_VALUES] =
{
OGL_CPL_PREFER_DXPRESENT_PREFER_DISABLED,
OGL_CPL_PREFER_DXPRESENT_PREFER_ENABLED,
OGL_CPL_PREFER_DXPRESENT_AUTO,
};
EValues_OGL_DEEP_COLOR_SCANOUT g_valuesOGL_DEEP_COLOR_SCANOUT[OGL_DEEP_COLOR_SCANOUT_NUM_VALUES] =
{
OGL_DEEP_COLOR_SCANOUT_DISABLE,
OGL_DEEP_COLOR_SCANOUT_ENABLE,
};
EValues_OGL_DEFAULT_SWAP_INTERVAL g_valuesOGL_DEFAULT_SWAP_INTERVAL[OGL_DEFAULT_SWAP_INTERVAL_NUM_VALUES] =
{
OGL_DEFAULT_SWAP_INTERVAL_TEAR,
OGL_DEFAULT_SWAP_INTERVAL_VSYNC_ONE,
OGL_DEFAULT_SWAP_INTERVAL_VSYNC,
OGL_DEFAULT_SWAP_INTERVAL_VALUE_MASK,
OGL_DEFAULT_SWAP_INTERVAL_FORCE_MASK,
OGL_DEFAULT_SWAP_INTERVAL_FORCE_OFF,
OGL_DEFAULT_SWAP_INTERVAL_FORCE_ON,
OGL_DEFAULT_SWAP_INTERVAL_APP_CONTROLLED,
OGL_DEFAULT_SWAP_INTERVAL_DISABLE,
};
EValues_OGL_DEFAULT_SWAP_INTERVAL_FRACTIONAL g_valuesOGL_DEFAULT_SWAP_INTERVAL_FRACTIONAL[OGL_DEFAULT_SWAP_INTERVAL_FRACTIONAL_NUM_VALUES] =
{
OGL_DEFAULT_SWAP_INTERVAL_FRACTIONAL_ZERO_SCANLINES,
OGL_DEFAULT_SWAP_INTERVAL_FRACTIONAL_ONE_FULL_FRAME_OF_SCANLINES,
};
EValues_OGL_DEFAULT_SWAP_INTERVAL_SIGN g_valuesOGL_DEFAULT_SWAP_INTERVAL_SIGN[OGL_DEFAULT_SWAP_INTERVAL_SIGN_NUM_VALUES] =
{
OGL_DEFAULT_SWAP_INTERVAL_SIGN_POSITIVE,
OGL_DEFAULT_SWAP_INTERVAL_SIGN_NEGATIVE,
};
EValues_OGL_EVENT_LOG_SEVERITY_THRESHOLD g_valuesOGL_EVENT_LOG_SEVERITY_THRESHOLD[OGL_EVENT_LOG_SEVERITY_THRESHOLD_NUM_VALUES] =
{
OGL_EVENT_LOG_SEVERITY_THRESHOLD_DISABLE,
OGL_EVENT_LOG_SEVERITY_THRESHOLD_CRITICAL,
OGL_EVENT_LOG_SEVERITY_THRESHOLD_WARNING,
OGL_EVENT_LOG_SEVERITY_THRESHOLD_INFORMATION,
OGL_EVENT_LOG_SEVERITY_THRESHOLD_ALL,
};
EValues_OGL_FORCE_BLIT g_valuesOGL_FORCE_BLIT[OGL_FORCE_BLIT_NUM_VALUES] =
{
OGL_FORCE_BLIT_ON,
OGL_FORCE_BLIT_OFF,
};
EValues_OGL_FORCE_STEREO g_valuesOGL_FORCE_STEREO[OGL_FORCE_STEREO_NUM_VALUES] =
{
OGL_FORCE_STEREO_OFF,
OGL_FORCE_STEREO_ON,
};
const wchar_t * g_valuesOGL_IMPLICIT_GPU_AFFINITY[OGL_IMPLICIT_GPU_AFFINITY_NUM_VALUES] =
{
OGL_IMPLICIT_GPU_AFFINITY_AUTOSELECT
};
EValues_OGL_OVERLAY_PIXEL_TYPE g_valuesOGL_OVERLAY_PIXEL_TYPE[OGL_OVERLAY_PIXEL_TYPE_NUM_VALUES] =
{
OGL_OVERLAY_PIXEL_TYPE_NONE,
OGL_OVERLAY_PIXEL_TYPE_CI,
OGL_OVERLAY_PIXEL_TYPE_RGBA,
OGL_OVERLAY_PIXEL_TYPE_CI_AND_RGBA,
};
EValues_OGL_OVERLAY_SUPPORT g_valuesOGL_OVERLAY_SUPPORT[OGL_OVERLAY_SUPPORT_NUM_VALUES] =
{
OGL_OVERLAY_SUPPORT_OFF,
OGL_OVERLAY_SUPPORT_ON,
OGL_OVERLAY_SUPPORT_FORCE_SW,
};
EValues_OGL_QUALITY_ENHANCEMENTS g_valuesOGL_QUALITY_ENHANCEMENTS[OGL_QUALITY_ENHANCEMENTS_NUM_VALUES] =
{
OGL_QUALITY_ENHANCEMENTS_HQUAL,
OGL_QUALITY_ENHANCEMENTS_QUAL,
OGL_QUALITY_ENHANCEMENTS_PERF,
OGL_QUALITY_ENHANCEMENTS_HPERF,
};
EValues_OGL_SINGLE_BACKDEPTH_BUFFER g_valuesOGL_SINGLE_BACKDEPTH_BUFFER[OGL_SINGLE_BACKDEPTH_BUFFER_NUM_VALUES] =
{
OGL_SINGLE_BACKDEPTH_BUFFER_DISABLE,
OGL_SINGLE_BACKDEPTH_BUFFER_ENABLE,
OGL_SINGLE_BACKDEPTH_BUFFER_USE_HW_DEFAULT,
};
EValues_OGL_SLI_MULTICAST g_valuesOGL_SLI_MULTICAST[OGL_SLI_MULTICAST_NUM_VALUES] =
{
OGL_SLI_MULTICAST_DISABLE,
OGL_SLI_MULTICAST_ENABLE,
OGL_SLI_MULTICAST_FORCE_DISABLE,
OGL_SLI_MULTICAST_ALLOW_MOSAIC,
};
EValues_OGL_THREAD_CONTROL g_valuesOGL_THREAD_CONTROL[OGL_THREAD_CONTROL_NUM_VALUES] =
{
OGL_THREAD_CONTROL_ENABLE,
OGL_THREAD_CONTROL_DISABLE,
};
EValues_OGL_TMON_LEVEL g_valuesOGL_TMON_LEVEL[OGL_TMON_LEVEL_NUM_VALUES] =
{
OGL_TMON_LEVEL_DISABLE,
OGL_TMON_LEVEL_CRITICAL,
OGL_TMON_LEVEL_WARNING,
OGL_TMON_LEVEL_INFORMATION,
OGL_TMON_LEVEL_MOST,
OGL_TMON_LEVEL_VERBOSE,
};
EValues_OGL_TRIPLE_BUFFER g_valuesOGL_TRIPLE_BUFFER[OGL_TRIPLE_BUFFER_NUM_VALUES] =
{
OGL_TRIPLE_BUFFER_DISABLED,
OGL_TRIPLE_BUFFER_ENABLED,
};
EValues_AA_BEHAVIOR_FLAGS g_valuesAA_BEHAVIOR_FLAGS[AA_BEHAVIOR_FLAGS_NUM_VALUES] =
{
AA_BEHAVIOR_FLAGS_NONE,
AA_BEHAVIOR_FLAGS_TREAT_OVERRIDE_AS_APP_CONTROLLED,
AA_BEHAVIOR_FLAGS_TREAT_OVERRIDE_AS_ENHANCE,
AA_BEHAVIOR_FLAGS_DISABLE_OVERRIDE,
AA_BEHAVIOR_FLAGS_TREAT_ENHANCE_AS_APP_CONTROLLED,
AA_BEHAVIOR_FLAGS_TREAT_ENHANCE_AS_OVERRIDE,
AA_BEHAVIOR_FLAGS_DISABLE_ENHANCE,
AA_BEHAVIOR_FLAGS_MAP_VCAA_TO_MULTISAMPLING,
AA_BEHAVIOR_FLAGS_SLI_DISABLE_TRANSPARENCY_SUPERSAMPLING,
AA_BEHAVIOR_FLAGS_DISABLE_CPLAA,
AA_BEHAVIOR_FLAGS_SKIP_RT_DIM_CHECK_FOR_ENHANCE,
AA_BEHAVIOR_FLAGS_DISABLE_SLIAA,
AA_BEHAVIOR_FLAGS_DEFAULT,
AA_BEHAVIOR_FLAGS_AA_RT_BPP_DIV_4,
AA_BEHAVIOR_FLAGS_AA_RT_BPP_DIV_4_SHIFT,
AA_BEHAVIOR_FLAGS_NON_AA_RT_BPP_DIV_4,
AA_BEHAVIOR_FLAGS_NON_AA_RT_BPP_DIV_4_SHIFT,
AA_BEHAVIOR_FLAGS_MASK,
};
EValues_AA_MODE_ALPHATOCOVERAGE g_valuesAA_MODE_ALPHATOCOVERAGE[AA_MODE_ALPHATOCOVERAGE_NUM_VALUES] =
{
AA_MODE_ALPHATOCOVERAGE_MODE_MASK,
AA_MODE_ALPHATOCOVERAGE_MODE_OFF,
AA_MODE_ALPHATOCOVERAGE_MODE_ON,
AA_MODE_ALPHATOCOVERAGE_MODE_MAX,
};
EValues_AA_MODE_GAMMACORRECTION g_valuesAA_MODE_GAMMACORRECTION[AA_MODE_GAMMACORRECTION_NUM_VALUES] =
{
AA_MODE_GAMMACORRECTION_MASK,
AA_MODE_GAMMACORRECTION_OFF,
AA_MODE_GAMMACORRECTION_ON_IF_FOS,
AA_MODE_GAMMACORRECTION_ON_ALWAYS,
AA_MODE_GAMMACORRECTION_MAX,
AA_MODE_GAMMACORRECTION_DEFAULT,
AA_MODE_GAMMACORRECTION_DEFAULT_TESLA,
AA_MODE_GAMMACORRECTION_DEFAULT_FERMI,
};
EValues_AA_MODE_METHOD g_valuesAA_MODE_METHOD[AA_MODE_METHOD_NUM_VALUES] =
{
AA_MODE_METHOD_NONE,
AA_MODE_METHOD_SUPERSAMPLE_2X_H,
AA_MODE_METHOD_SUPERSAMPLE_2X_V,
AA_MODE_METHOD_SUPERSAMPLE_1_5X1_5,
AA_MODE_METHOD_FREE_0x03,
AA_MODE_METHOD_FREE_0x04,
AA_MODE_METHOD_SUPERSAMPLE_4X,
AA_MODE_METHOD_SUPERSAMPLE_4X_BIAS,
AA_MODE_METHOD_SUPERSAMPLE_4X_GAUSSIAN,
AA_MODE_METHOD_FREE_0x08,
AA_MODE_METHOD_FREE_0x09,
AA_MODE_METHOD_SUPERSAMPLE_9X,
AA_MODE_METHOD_SUPERSAMPLE_9X_BIAS,
AA_MODE_METHOD_SUPERSAMPLE_16X,
AA_MODE_METHOD_SUPERSAMPLE_16X_BIAS,
AA_MODE_METHOD_MULTISAMPLE_2X_DIAGONAL,
AA_MODE_METHOD_MULTISAMPLE_2X_QUINCUNX,
AA_MODE_METHOD_MULTISAMPLE_4X,
AA_MODE_METHOD_FREE_0x11,
AA_MODE_METHOD_MULTISAMPLE_4X_GAUSSIAN,
AA_MODE_METHOD_MIXEDSAMPLE_4X_SKEWED_4TAP,
AA_MODE_METHOD_FREE_0x14,
AA_MODE_METHOD_FREE_0x15,
AA_MODE_METHOD_MIXEDSAMPLE_6X,
AA_MODE_METHOD_MIXEDSAMPLE_6X_SKEWED_6TAP,
AA_MODE_METHOD_MIXEDSAMPLE_8X,
AA_MODE_METHOD_MIXEDSAMPLE_8X_SKEWED_8TAP,
AA_MODE_METHOD_MIXEDSAMPLE_16X,
AA_MODE_METHOD_MULTISAMPLE_4X_GAMMA,
AA_MODE_METHOD_MULTISAMPLE_16X,
AA_MODE_METHOD_VCAA_32X_8v24,
AA_MODE_METHOD_CORRUPTION_CHECK,
AA_MODE_METHOD_6X_CT,
AA_MODE_METHOD_MULTISAMPLE_2X_DIAGONAL_GAMMA,
AA_MODE_METHOD_SUPERSAMPLE_4X_GAMMA,
AA_MODE_METHOD_MULTISAMPLE_4X_FOSGAMMA,
AA_MODE_METHOD_MULTISAMPLE_2X_DIAGONAL_FOSGAMMA,
AA_MODE_METHOD_SUPERSAMPLE_4X_FOSGAMMA,
AA_MODE_METHOD_MULTISAMPLE_8X,
AA_MODE_METHOD_VCAA_8X_4v4,
AA_MODE_METHOD_VCAA_16X_4v12,
AA_MODE_METHOD_VCAA_16X_8v8,
AA_MODE_METHOD_MIXEDSAMPLE_32X,
AA_MODE_METHOD_SUPERVCAA_64X_4v12,
AA_MODE_METHOD_SUPERVCAA_64X_8v8,
AA_MODE_METHOD_MIXEDSAMPLE_64X,
AA_MODE_METHOD_MIXEDSAMPLE_128X,
AA_MODE_METHOD_COUNT,
AA_MODE_METHOD_METHOD_MASK,
AA_MODE_METHOD_METHOD_MAX,
};
EValues_AA_MODE_REPLAY g_valuesAA_MODE_REPLAY[AA_MODE_REPLAY_NUM_VALUES] =
{
AA_MODE_REPLAY_SAMPLES_MASK,
AA_MODE_REPLAY_SAMPLES_ONE,
AA_MODE_REPLAY_SAMPLES_TWO,
AA_MODE_REPLAY_SAMPLES_FOUR,
AA_MODE_REPLAY_SAMPLES_EIGHT,
AA_MODE_REPLAY_SAMPLES_MAX,
AA_MODE_REPLAY_MODE_MASK,
AA_MODE_REPLAY_MODE_OFF,
AA_MODE_REPLAY_MODE_ALPHA_TEST,
AA_MODE_REPLAY_MODE_PIXEL_KILL,
AA_MODE_REPLAY_MODE_DYN_BRANCH,
AA_MODE_REPLAY_MODE_OPTIMAL,
AA_MODE_REPLAY_MODE_ALL,
AA_MODE_REPLAY_MODE_MAX,
AA_MODE_REPLAY_TRANSPARENCY,
AA_MODE_REPLAY_DISALLOW_TRAA,
AA_MODE_REPLAY_TRANSPARENCY_DEFAULT,
AA_MODE_REPLAY_TRANSPARENCY_DEFAULT_TESLA,
AA_MODE_REPLAY_TRANSPARENCY_DEFAULT_FERMI,
AA_MODE_REPLAY_MASK,
};
EValues_AA_MODE_SELECTOR g_valuesAA_MODE_SELECTOR[AA_MODE_SELECTOR_NUM_VALUES] =
{
AA_MODE_SELECTOR_MASK,
AA_MODE_SELECTOR_APP_CONTROL,
AA_MODE_SELECTOR_OVERRIDE,
AA_MODE_SELECTOR_ENHANCE,
AA_MODE_SELECTOR_MAX,
};
EValues_AA_MODE_SELECTOR_SLIAA g_valuesAA_MODE_SELECTOR_SLIAA[AA_MODE_SELECTOR_SLIAA_NUM_VALUES] =
{
AA_MODE_SELECTOR_SLIAA_DISABLED,
AA_MODE_SELECTOR_SLIAA_ENABLED,
};
EValues_ANISO_MODE_LEVEL g_valuesANISO_MODE_LEVEL[ANISO_MODE_LEVEL_NUM_VALUES] =
{
ANISO_MODE_LEVEL_MASK,
ANISO_MODE_LEVEL_NONE_POINT,
ANISO_MODE_LEVEL_NONE_LINEAR,
ANISO_MODE_LEVEL_MAX,
ANISO_MODE_LEVEL_DEFAULT,
};
EValues_ANISO_MODE_SELECTOR g_valuesANISO_MODE_SELECTOR[ANISO_MODE_SELECTOR_NUM_VALUES] =
{
ANISO_MODE_SELECTOR_MASK,
ANISO_MODE_SELECTOR_APP,
ANISO_MODE_SELECTOR_USER,
ANISO_MODE_SELECTOR_COND,
ANISO_MODE_SELECTOR_MAX,
ANISO_MODE_SELECTOR_DEFAULT,
};
EValues_ANSEL_ALLOW g_valuesANSEL_ALLOW[ANSEL_ALLOW_NUM_VALUES] =
{
ANSEL_ALLOW_DISALLOWED,
ANSEL_ALLOW_ALLOWED,
};
EValues_ANSEL_ALLOWLISTED g_valuesANSEL_ALLOWLISTED[ANSEL_ALLOWLISTED_NUM_VALUES] =
{
ANSEL_ALLOWLISTED_DISALLOWED,
ANSEL_ALLOWLISTED_ALLOWED,
};
EValues_ANSEL_ENABLE g_valuesANSEL_ENABLE[ANSEL_ENABLE_NUM_VALUES] =
{
ANSEL_ENABLE_OFF,
ANSEL_ENABLE_ON,
};
EValues_APPLICATION_PROFILE_NOTIFICATION_TIMEOUT g_valuesAPPLICATION_PROFILE_NOTIFICATION_TIMEOUT[APPLICATION_PROFILE_NOTIFICATION_TIMEOUT_NUM_VALUES] =
{
APPLICATION_PROFILE_NOTIFICATION_TIMEOUT_DISABLED,
APPLICATION_PROFILE_NOTIFICATION_TIMEOUT_NINE_SECONDS,
APPLICATION_PROFILE_NOTIFICATION_TIMEOUT_FIFTEEN_SECONDS,
APPLICATION_PROFILE_NOTIFICATION_TIMEOUT_THIRTY_SECONDS,
APPLICATION_PROFILE_NOTIFICATION_TIMEOUT_ONE_MINUTE,
APPLICATION_PROFILE_NOTIFICATION_TIMEOUT_TWO_MINUTES,
};
EValues_BATTERY_BOOST_APP_FPS g_valuesBATTERY_BOOST_APP_FPS[BATTERY_BOOST_APP_FPS_NUM_VALUES] =
{
BATTERY_BOOST_APP_FPS_MIN,
BATTERY_BOOST_APP_FPS_MAX,
BATTERY_BOOST_APP_FPS_NO_OVERRIDE,
};
EValues_CPL_HIDDEN_PROFILE g_valuesCPL_HIDDEN_PROFILE[CPL_HIDDEN_PROFILE_NUM_VALUES] =
{
CPL_HIDDEN_PROFILE_DISABLED,
CPL_HIDDEN_PROFILE_ENABLED,
};
const wchar_t * g_valuesCUDA_EXCLUDED_GPUS[CUDA_EXCLUDED_GPUS_NUM_VALUES] =
{
CUDA_EXCLUDED_GPUS_NONE
};
const wchar_t * g_valuesD3DOGL_GPU_MAX_POWER[D3DOGL_GPU_MAX_POWER_NUM_VALUES] =
{
D3DOGL_GPU_MAX_POWER_DEFAULTPOWER
};
EValues_EXPORT_PERF_COUNTERS g_valuesEXPORT_PERF_COUNTERS[EXPORT_PERF_COUNTERS_NUM_VALUES] =
{
EXPORT_PERF_COUNTERS_OFF,
EXPORT_PERF_COUNTERS_ON,
};
EValues_EXTERNAL_QUIET_MODE g_valuesEXTERNAL_QUIET_MODE[EXTERNAL_QUIET_MODE_NUM_VALUES] =
{
EXTERNAL_QUIET_MODE_ON,
EXTERNAL_QUIET_MODE_OFF,
};
EValues_FRL_FPS g_valuesFRL_FPS[FRL_FPS_NUM_VALUES] =
{
FRL_FPS_DISABLED,
FRL_FPS_MIN,
FRL_FPS_MAX,
};
EValues_FXAA_ALLOW g_valuesFXAA_ALLOW[FXAA_ALLOW_NUM_VALUES] =
{
FXAA_ALLOW_DISALLOWED,
FXAA_ALLOW_ALLOWED,
};
EValues_FXAA_ENABLE g_valuesFXAA_ENABLE[FXAA_ENABLE_NUM_VALUES] =
{
FXAA_ENABLE_OFF,
FXAA_ENABLE_ON,
};
EValues_FXAA_INDICATOR_ENABLE g_valuesFXAA_INDICATOR_ENABLE[FXAA_INDICATOR_ENABLE_NUM_VALUES] =
{
FXAA_INDICATOR_ENABLE_OFF,
FXAA_INDICATOR_ENABLE_ON,
};
EValues_LATENCY_INDICATOR_AUTOALIGN g_valuesLATENCY_INDICATOR_AUTOALIGN[LATENCY_INDICATOR_AUTOALIGN_NUM_VALUES] =
{
LATENCY_INDICATOR_AUTOALIGN_DISABLED,
LATENCY_INDICATOR_AUTOALIGN_ENABLED,
};
EValues_MCSFRSHOWSPLIT g_valuesMCSFRSHOWSPLIT[MCSFRSHOWSPLIT_NUM_VALUES] =
{
MCSFRSHOWSPLIT_DISABLED,
MCSFRSHOWSPLIT_ENABLED,
};
EValues_NV_QUALITY_UPSCALING g_valuesNV_QUALITY_UPSCALING[NV_QUALITY_UPSCALING_NUM_VALUES] =
{
NV_QUALITY_UPSCALING_OFF,
NV_QUALITY_UPSCALING_ON,
};
EValues_OPTIMUS_MAXAA g_valuesOPTIMUS_MAXAA[OPTIMUS_MAXAA_NUM_VALUES] =
{
OPTIMUS_MAXAA_MIN,
OPTIMUS_MAXAA_MAX,
};
EValues_PHYSXINDICATOR g_valuesPHYSXINDICATOR[PHYSXINDICATOR_NUM_VALUES] =
{
PHYSXINDICATOR_DISABLED,
PHYSXINDICATOR_ENABLED,
};
EValues_PREFERRED_PSTATE g_valuesPREFERRED_PSTATE[PREFERRED_PSTATE_NUM_VALUES] =
{
PREFERRED_PSTATE_ADAPTIVE,
PREFERRED_PSTATE_PREFER_MAX,
PREFERRED_PSTATE_DRIVER_CONTROLLED,
PREFERRED_PSTATE_PREFER_CONSISTENT_PERFORMANCE,
PREFERRED_PSTATE_PREFER_MIN,
PREFERRED_PSTATE_OPTIMAL_POWER,
PREFERRED_PSTATE_MIN,
PREFERRED_PSTATE_MAX,
};
EValues_PREVENT_UI_AF_OVERRIDE g_valuesPREVENT_UI_AF_OVERRIDE[PREVENT_UI_AF_OVERRIDE_NUM_VALUES] =
{
PREVENT_UI_AF_OVERRIDE_OFF,
PREVENT_UI_AF_OVERRIDE_ON,
};
EValues_SHIM_MCCOMPAT g_valuesSHIM_MCCOMPAT[SHIM_MCCOMPAT_NUM_VALUES] =
{
SHIM_MCCOMPAT_INTEGRATED,
SHIM_MCCOMPAT_ENABLE,
SHIM_MCCOMPAT_USER_EDITABLE,
SHIM_MCCOMPAT_MASK,
SHIM_MCCOMPAT_VIDEO_MASK,
SHIM_MCCOMPAT_VARYING_BIT,
SHIM_MCCOMPAT_AUTO_SELECT,
SHIM_MCCOMPAT_OVERRIDE_BIT,
};
EValues_SHIM_RENDERING_MODE g_valuesSHIM_RENDERING_MODE[SHIM_RENDERING_MODE_NUM_VALUES] =
{
SHIM_RENDERING_MODE_INTEGRATED,
SHIM_RENDERING_MODE_ENABLE,
SHIM_RENDERING_MODE_USER_EDITABLE,
SHIM_RENDERING_MODE_MASK,
SHIM_RENDERING_MODE_VIDEO_MASK,
SHIM_RENDERING_MODE_VARYING_BIT,
SHIM_RENDERING_MODE_AUTO_SELECT,
SHIM_RENDERING_MODE_OVERRIDE_BIT,
};
EValues_SHIM_RENDERING_OPTIONS g_valuesSHIM_RENDERING_OPTIONS[SHIM_RENDERING_OPTIONS_NUM_VALUES] =
{
SHIM_RENDERING_OPTIONS_DEFAULT_RENDERING_MODE,
SHIM_RENDERING_OPTIONS_DISABLE_ASYNC_PRESENT,
SHIM_RENDERING_OPTIONS_EHSHELL_DETECT,
SHIM_RENDERING_OPTIONS_FLASHPLAYER_HOST_DETECT,
SHIM_RENDERING_OPTIONS_VIDEO_DRM_APP_DETECT,
SHIM_RENDERING_OPTIONS_IGNORE_OVERRIDES,
SHIM_RENDERING_OPTIONS_RESERVED1,
SHIM_RENDERING_OPTIONS_ENABLE_DWM_ASYNC_PRESENT,
SHIM_RENDERING_OPTIONS_RESERVED2,
SHIM_RENDERING_OPTIONS_ALLOW_INHERITANCE,
SHIM_RENDERING_OPTIONS_DISABLE_WRAPPERS,
SHIM_RENDERING_OPTIONS_DISABLE_DXGI_WRAPPERS,
SHIM_RENDERING_OPTIONS_PRUNE_UNSUPPORTED_FORMATS,
SHIM_RENDERING_OPTIONS_ENABLE_ALPHA_FORMAT,
SHIM_RENDERING_OPTIONS_IGPU_TRANSCODING,
SHIM_RENDERING_OPTIONS_DISABLE_CUDA,
SHIM_RENDERING_OPTIONS_ALLOW_CP_CAPS_FOR_VIDEO,
SHIM_RENDERING_OPTIONS_IGPU_TRANSCODING_FWD_OPTIMUS,
SHIM_RENDERING_OPTIONS_DISABLE_DURING_SECURE_BOOT,
SHIM_RENDERING_OPTIONS_INVERT_FOR_QUADRO,
SHIM_RENDERING_OPTIONS_INVERT_FOR_MSHYBRID,
SHIM_RENDERING_OPTIONS_REGISTER_PROCESS_ENABLE_GOLD,
SHIM_RENDERING_OPTIONS_HANDLE_WINDOWED_MODE_PERF_OPT,
SHIM_RENDERING_OPTIONS_HANDLE_WIN7_ASYNC_RUNTIME_BUG,
SHIM_RENDERING_OPTIONS_EXPLICIT_ADAPTER_OPTED_BY_APP,
SHIM_RENDERING_OPTIONS_ALLOW_DYNAMIC_DISPLAY_MUX_SWITCH,
SHIM_RENDERING_OPTIONS_DISALLOW_DYNAMIC_DISPLAY_MUX_SWITCH,
SHIM_RENDERING_OPTIONS_DISABLE_TURING_POWER_POLICY,
SHIM_RENDERING_OPTIONS_ALLOW_DYNAMIC_DISPLAY_MUX_SWITCH_MDM,
SHIM_RENDERING_OPTIONS_DISALLOW_DYNAMIC_DISPLAY_MUX_SWITCH_MDM,
};
EValues_SLI_GPU_COUNT g_valuesSLI_GPU_COUNT[SLI_GPU_COUNT_NUM_VALUES] =
{
SLI_GPU_COUNT_AUTOSELECT,
SLI_GPU_COUNT_ONE,
SLI_GPU_COUNT_TWO,
SLI_GPU_COUNT_THREE,
SLI_GPU_COUNT_FOUR,
};
EValues_SLI_PREDEFINED_GPU_COUNT g_valuesSLI_PREDEFINED_GPU_COUNT[SLI_PREDEFINED_GPU_COUNT_NUM_VALUES] =
{
SLI_PREDEFINED_GPU_COUNT_AUTOSELECT,
SLI_PREDEFINED_GPU_COUNT_ONE,
SLI_PREDEFINED_GPU_COUNT_TWO,
SLI_PREDEFINED_GPU_COUNT_THREE,
SLI_PREDEFINED_GPU_COUNT_FOUR,
};
EValues_SLI_PREDEFINED_GPU_COUNT_DX10 g_valuesSLI_PREDEFINED_GPU_COUNT_DX10[SLI_PREDEFINED_GPU_COUNT_DX10_NUM_VALUES] =
{
SLI_PREDEFINED_GPU_COUNT_DX10_AUTOSELECT,
SLI_PREDEFINED_GPU_COUNT_DX10_ONE,
SLI_PREDEFINED_GPU_COUNT_DX10_TWO,
SLI_PREDEFINED_GPU_COUNT_DX10_THREE,
SLI_PREDEFINED_GPU_COUNT_DX10_FOUR,
};
EValues_SLI_PREDEFINED_MODE g_valuesSLI_PREDEFINED_MODE[SLI_PREDEFINED_MODE_NUM_VALUES] =
{
SLI_PREDEFINED_MODE_AUTOSELECT,
SLI_PREDEFINED_MODE_FORCE_SINGLE,
SLI_PREDEFINED_MODE_FORCE_AFR,
SLI_PREDEFINED_MODE_FORCE_AFR2,
SLI_PREDEFINED_MODE_FORCE_SFR,
SLI_PREDEFINED_MODE_FORCE_AFR_OF_SFR__FALLBACK_3AFR,
};
EValues_SLI_PREDEFINED_MODE_DX10 g_valuesSLI_PREDEFINED_MODE_DX10[SLI_PREDEFINED_MODE_DX10_NUM_VALUES] =
{
SLI_PREDEFINED_MODE_DX10_AUTOSELECT,
SLI_PREDEFINED_MODE_DX10_FORCE_SINGLE,
SLI_PREDEFINED_MODE_DX10_FORCE_AFR,
SLI_PREDEFINED_MODE_DX10_FORCE_AFR2,
SLI_PREDEFINED_MODE_DX10_FORCE_SFR,
SLI_PREDEFINED_MODE_DX10_FORCE_AFR_OF_SFR__FALLBACK_3AFR,
};
EValues_SLI_RENDERING_MODE g_valuesSLI_RENDERING_MODE[SLI_RENDERING_MODE_NUM_VALUES] =
{
SLI_RENDERING_MODE_AUTOSELECT,
SLI_RENDERING_MODE_FORCE_SINGLE,
SLI_RENDERING_MODE_FORCE_AFR,
SLI_RENDERING_MODE_FORCE_AFR2,
SLI_RENDERING_MODE_FORCE_SFR,
SLI_RENDERING_MODE_FORCE_AFR_OF_SFR__FALLBACK_3AFR,
};
EValues_VRPRERENDERLIMIT g_valuesVRPRERENDERLIMIT[VRPRERENDERLIMIT_NUM_VALUES] =
{
VRPRERENDERLIMIT_MIN,
VRPRERENDERLIMIT_MAX,
VRPRERENDERLIMIT_APP_CONTROLLED,
VRPRERENDERLIMIT_DEFAULT,
};
EValues_VRRFEATUREINDICATOR g_valuesVRRFEATUREINDICATOR[VRRFEATUREINDICATOR_NUM_VALUES] =
{
VRRFEATUREINDICATOR_DISABLED,
VRRFEATUREINDICATOR_ENABLED,
};
EValues_VRROVERLAYINDICATOR g_valuesVRROVERLAYINDICATOR[VRROVERLAYINDICATOR_NUM_VALUES] =
{
VRROVERLAYINDICATOR_DISABLED,
VRROVERLAYINDICATOR_ENABLED,
};
EValues_VRRREQUESTSTATE g_valuesVRRREQUESTSTATE[VRRREQUESTSTATE_NUM_VALUES] =
{
VRRREQUESTSTATE_DISABLED,
VRRREQUESTSTATE_FULLSCREEN_ONLY,
VRRREQUESTSTATE_FULLSCREEN_AND_WINDOWED,
};
EValues_VRR_APP_OVERRIDE g_valuesVRR_APP_OVERRIDE[VRR_APP_OVERRIDE_NUM_VALUES] =
{
VRR_APP_OVERRIDE_ALLOW,
VRR_APP_OVERRIDE_FORCE_OFF,
VRR_APP_OVERRIDE_DISALLOW,
VRR_APP_OVERRIDE_ULMB,
VRR_APP_OVERRIDE_FIXED_REFRESH,
};
EValues_VRR_APP_OVERRIDE_REQUEST_STATE g_valuesVRR_APP_OVERRIDE_REQUEST_STATE[VRR_APP_OVERRIDE_REQUEST_STATE_NUM_VALUES] =
{
VRR_APP_OVERRIDE_REQUEST_STATE_ALLOW,
VRR_APP_OVERRIDE_REQUEST_STATE_FORCE_OFF,
VRR_APP_OVERRIDE_REQUEST_STATE_DISALLOW,
VRR_APP_OVERRIDE_REQUEST_STATE_ULMB,
VRR_APP_OVERRIDE_REQUEST_STATE_FIXED_REFRESH,
};
EValues_VRR_MODE g_valuesVRR_MODE[VRR_MODE_NUM_VALUES] =
{
VRR_MODE_DISABLED,
VRR_MODE_FULLSCREEN_ONLY,
VRR_MODE_FULLSCREEN_AND_WINDOWED,
};
EValues_VSYNCSMOOTHAFR g_valuesVSYNCSMOOTHAFR[VSYNCSMOOTHAFR_NUM_VALUES] =
{
VSYNCSMOOTHAFR_OFF,
VSYNCSMOOTHAFR_ON,
};
EValues_VSYNCVRRCONTROL g_valuesVSYNCVRRCONTROL[VSYNCVRRCONTROL_NUM_VALUES] =
{
VSYNCVRRCONTROL_DISABLE,
VSYNCVRRCONTROL_ENABLE,
VSYNCVRRCONTROL_NOTSUPPORTED,
};
EValues_VSYNC_BEHAVIOR_FLAGS g_valuesVSYNC_BEHAVIOR_FLAGS[VSYNC_BEHAVIOR_FLAGS_NUM_VALUES] =
{
VSYNC_BEHAVIOR_FLAGS_NONE,
VSYNC_BEHAVIOR_FLAGS_DEFAULT,
VSYNC_BEHAVIOR_FLAGS_IGNORE_FLIPINTERVAL_MULTIPLE,
};
EValues_WKS_API_STEREO_EYES_EXCHANGE g_valuesWKS_API_STEREO_EYES_EXCHANGE[WKS_API_STEREO_EYES_EXCHANGE_NUM_VALUES] =
{
WKS_API_STEREO_EYES_EXCHANGE_OFF,
WKS_API_STEREO_EYES_EXCHANGE_ON,
};
EValues_WKS_API_STEREO_MODE g_valuesWKS_API_STEREO_MODE[WKS_API_STEREO_MODE_NUM_VALUES] =
{
WKS_API_STEREO_MODE_SHUTTER_GLASSES,
WKS_API_STEREO_MODE_VERTICAL_INTERLACED,
WKS_API_STEREO_MODE_TWINVIEW,
WKS_API_STEREO_MODE_NV17_SHUTTER_GLASSES_AUTO,
WKS_API_STEREO_MODE_NV17_SHUTTER_GLASSES_DAC0,
WKS_API_STEREO_MODE_NV17_SHUTTER_GLASSES_DAC1,
WKS_API_STEREO_MODE_COLOR_LINE,
WKS_API_STEREO_MODE_COLOR_INTERLEAVED,
WKS_API_STEREO_MODE_ANAGLYPH,
WKS_API_STEREO_MODE_HORIZONTAL_INTERLACED,
WKS_API_STEREO_MODE_SIDE_FIELD,
WKS_API_STEREO_MODE_SUB_FIELD,
WKS_API_STEREO_MODE_CHECKERBOARD,
WKS_API_STEREO_MODE_INVERSE_CHECKERBOARD,
WKS_API_STEREO_MODE_TRIDELITY_SL,
WKS_API_STEREO_MODE_TRIDELITY_MV,
WKS_API_STEREO_MODE_SEEFRONT,
WKS_API_STEREO_MODE_STEREO_MIRROR,
WKS_API_STEREO_MODE_FRAME_SEQUENTIAL,
WKS_API_STEREO_MODE_AUTODETECT_PASSIVE_MODE,
WKS_API_STEREO_MODE_AEGIS_DT_FRAME_SEQUENTIAL,
WKS_API_STEREO_MODE_OEM_EMITTER_FRAME_SEQUENTIAL,
WKS_API_STEREO_MODE_DP_INBAND,
WKS_API_STEREO_MODE_USE_HW_DEFAULT,
WKS_API_STEREO_MODE_DEFAULT_GL,
};
EValues_WKS_STEREO_DONGLE_SUPPORT g_valuesWKS_STEREO_DONGLE_SUPPORT[WKS_STEREO_DONGLE_SUPPORT_NUM_VALUES] =
{
WKS_STEREO_DONGLE_SUPPORT_OFF,
WKS_STEREO_DONGLE_SUPPORT_DAC,
WKS_STEREO_DONGLE_SUPPORT_DLP,
};
EValues_WKS_STEREO_SUPPORT g_valuesWKS_STEREO_SUPPORT[WKS_STEREO_SUPPORT_NUM_VALUES] =
{
WKS_STEREO_SUPPORT_OFF,
WKS_STEREO_SUPPORT_ON,
};
EValues_WKS_STEREO_SWAP_MODE g_valuesWKS_STEREO_SWAP_MODE[WKS_STEREO_SWAP_MODE_NUM_VALUES] =
{
WKS_STEREO_SWAP_MODE_APPLICATION_CONTROL,
WKS_STEREO_SWAP_MODE_PER_EYE,
WKS_STEREO_SWAP_MODE_PER_EYE_PAIR,
WKS_STEREO_SWAP_MODE_LEGACY_BEHAVIOR,
WKS_STEREO_SWAP_MODE_PER_EYE_FOR_SWAP_GROUP,
};
EValues_AO_MODE g_valuesAO_MODE[AO_MODE_NUM_VALUES] =
{
AO_MODE_OFF,
AO_MODE_LOW,
AO_MODE_MEDIUM,
AO_MODE_HIGH,
};
EValues_AO_MODE_ACTIVE g_valuesAO_MODE_ACTIVE[AO_MODE_ACTIVE_NUM_VALUES] =
{
AO_MODE_ACTIVE_DISABLED,
AO_MODE_ACTIVE_ENABLED,
};
EValues_AUTO_LODBIASADJUST g_valuesAUTO_LODBIASADJUST[AUTO_LODBIASADJUST_NUM_VALUES] =
{
AUTO_LODBIASADJUST_OFF,
AUTO_LODBIASADJUST_ON,
};
EValues_EXPORT_PERF_COUNTERS_DX9_ONLY g_valuesEXPORT_PERF_COUNTERS_DX9_ONLY[EXPORT_PERF_COUNTERS_DX9_ONLY_NUM_VALUES] =
{
EXPORT_PERF_COUNTERS_DX9_ONLY_OFF,
EXPORT_PERF_COUNTERS_DX9_ONLY_ON,
};
EValues_LODBIASADJUST g_valuesLODBIASADJUST[LODBIASADJUST_NUM_VALUES] =
{
LODBIASADJUST_MIN,
LODBIASADJUST_MAX,
};
EValues_MAXWELL_B_SAMPLE_INTERLEAVE g_valuesMAXWELL_B_SAMPLE_INTERLEAVE[MAXWELL_B_SAMPLE_INTERLEAVE_NUM_VALUES] =
{
MAXWELL_B_SAMPLE_INTERLEAVE_OFF,
MAXWELL_B_SAMPLE_INTERLEAVE_ON,
};
EValues_PRERENDERLIMIT g_valuesPRERENDERLIMIT[PRERENDERLIMIT_NUM_VALUES] =
{
PRERENDERLIMIT_MIN,
PRERENDERLIMIT_MAX,
PRERENDERLIMIT_APP_CONTROLLED,
};
EValues_PS_SHADERDISKCACHE g_valuesPS_SHADERDISKCACHE[PS_SHADERDISKCACHE_NUM_VALUES] =
{
PS_SHADERDISKCACHE_OFF,
PS_SHADERDISKCACHE_ON,
};
EValues_PS_SHADERDISKCACHE_MAX_SIZE g_valuesPS_SHADERDISKCACHE_MAX_SIZE[PS_SHADERDISKCACHE_MAX_SIZE_NUM_VALUES] =
{
PS_SHADERDISKCACHE_MAX_SIZE_MIN,
PS_SHADERDISKCACHE_MAX_SIZE_MAX,
};
EValues_PS_TEXFILTER_ANISO_OPTS2 g_valuesPS_TEXFILTER_ANISO_OPTS2[PS_TEXFILTER_ANISO_OPTS2_NUM_VALUES] =
{
PS_TEXFILTER_ANISO_OPTS2_OFF,
PS_TEXFILTER_ANISO_OPTS2_ON,
};
EValues_PS_TEXFILTER_BILINEAR_IN_ANISO g_valuesPS_TEXFILTER_BILINEAR_IN_ANISO[PS_TEXFILTER_BILINEAR_IN_ANISO_NUM_VALUES] =
{
PS_TEXFILTER_BILINEAR_IN_ANISO_OFF,
PS_TEXFILTER_BILINEAR_IN_ANISO_ON,
};
EValues_PS_TEXFILTER_DISABLE_TRILIN_SLOPE g_valuesPS_TEXFILTER_DISABLE_TRILIN_SLOPE[PS_TEXFILTER_DISABLE_TRILIN_SLOPE_NUM_VALUES] =
{
PS_TEXFILTER_DISABLE_TRILIN_SLOPE_OFF,
PS_TEXFILTER_DISABLE_TRILIN_SLOPE_ON,
};
EValues_PS_TEXFILTER_NO_NEG_LODBIAS g_valuesPS_TEXFILTER_NO_NEG_LODBIAS[PS_TEXFILTER_NO_NEG_LODBIAS_NUM_VALUES] =
{
PS_TEXFILTER_NO_NEG_LODBIAS_OFF,
PS_TEXFILTER_NO_NEG_LODBIAS_ON,
};
EValues_QUALITY_ENHANCEMENTS g_valuesQUALITY_ENHANCEMENTS[QUALITY_ENHANCEMENTS_NUM_VALUES] =
{
QUALITY_ENHANCEMENTS_HIGHQUALITY,
QUALITY_ENHANCEMENTS_QUALITY,
QUALITY_ENHANCEMENTS_PERFORMANCE,
QUALITY_ENHANCEMENTS_HIGHPERFORMANCE,
};
EValues_QUALITY_ENHANCEMENT_SUBSTITUTION g_valuesQUALITY_ENHANCEMENT_SUBSTITUTION[QUALITY_ENHANCEMENT_SUBSTITUTION_NUM_VALUES] =
{
QUALITY_ENHANCEMENT_SUBSTITUTION_NO_SUBSTITUTION,
QUALITY_ENHANCEMENT_SUBSTITUTION_HIGHQUALITY_BECOMES_QUALITY,
};
EValues_REFRESH_RATE_OVERRIDE g_valuesREFRESH_RATE_OVERRIDE[REFRESH_RATE_OVERRIDE_NUM_VALUES] =
{
REFRESH_RATE_OVERRIDE_APPLICATION_CONTROLLED,
REFRESH_RATE_OVERRIDE_HIGHEST_AVAILABLE,
REFRESH_RATE_OVERRIDE_LOW_LATENCY_RR_MASK,
};
EValues_SET_POWER_THROTTLE_FOR_PCIe_COMPLIANCE g_valuesSET_POWER_THROTTLE_FOR_PCIe_COMPLIANCE[SET_POWER_THROTTLE_FOR_PCIe_COMPLIANCE_NUM_VALUES] =
{
SET_POWER_THROTTLE_FOR_PCIe_COMPLIANCE_OFF,
SET_POWER_THROTTLE_FOR_PCIe_COMPLIANCE_ON,
};
EValues_SET_VAB_DATA g_valuesSET_VAB_DATA[SET_VAB_DATA_NUM_VALUES] =
{
SET_VAB_DATA_ZERO,
SET_VAB_DATA_UINT_ONE,
SET_VAB_DATA_FLOAT_ONE,
SET_VAB_DATA_FLOAT_POS_INF,
SET_VAB_DATA_FLOAT_NAN,
SET_VAB_DATA_USE_API_DEFAULTS,
};
EValues_VSYNCMODE g_valuesVSYNCMODE[VSYNCMODE_NUM_VALUES] =
{
VSYNCMODE_PASSIVE,
VSYNCMODE_FORCEOFF,
VSYNCMODE_FORCEON,
VSYNCMODE_FLIPINTERVAL2,
VSYNCMODE_FLIPINTERVAL3,
VSYNCMODE_FLIPINTERVAL4,
VSYNCMODE_VIRTUAL,
};
EValues_VSYNCTEARCONTROL g_valuesVSYNCTEARCONTROL[VSYNCTEARCONTROL_NUM_VALUES] =
{
VSYNCTEARCONTROL_DISABLE,
VSYNCTEARCONTROL_ENABLE,
};
SettingDWORDNameString mapSettingDWORD[TOTAL_DWORD_SETTING_NUM] =
{
{OGL_AA_LINE_GAMMA_ID, OGL_AA_LINE_GAMMA_STRING, 4, (NvU32 *)g_valuesOGL_AA_LINE_GAMMA, OGL_AA_LINE_GAMMA_DISABLED},
{OGL_CPL_GDI_COMPATIBILITY_ID, OGL_CPL_GDI_COMPATIBILITY_STRING, 3, (NvU32 *)g_valuesOGL_CPL_GDI_COMPATIBILITY, OGL_CPL_GDI_COMPATIBILITY_AUTO},
{OGL_CPL_PREFER_DXPRESENT_ID, OGL_CPL_PREFER_DXPRESENT_STRING, 3, (NvU32 *)g_valuesOGL_CPL_PREFER_DXPRESENT, OGL_CPL_PREFER_DXPRESENT_AUTO},
{OGL_DEEP_COLOR_SCANOUT_ID, OGL_DEEP_COLOR_SCANOUT_STRING, 2, (NvU32 *)g_valuesOGL_DEEP_COLOR_SCANOUT, OGL_DEEP_COLOR_SCANOUT_ENABLE},
{OGL_DEFAULT_SWAP_INTERVAL_ID, OGL_DEFAULT_SWAP_INTERVAL_STRING, 9, (NvU32 *)g_valuesOGL_DEFAULT_SWAP_INTERVAL, OGL_DEFAULT_SWAP_INTERVAL_VSYNC_ONE},
{OGL_DEFAULT_SWAP_INTERVAL_FRACTIONAL_ID, OGL_DEFAULT_SWAP_INTERVAL_FRACTIONAL_STRING, 2, (NvU32 *)g_valuesOGL_DEFAULT_SWAP_INTERVAL_FRACTIONAL, 0x00000000},
{OGL_DEFAULT_SWAP_INTERVAL_SIGN_ID, OGL_DEFAULT_SWAP_INTERVAL_SIGN_STRING, 2, (NvU32 *)g_valuesOGL_DEFAULT_SWAP_INTERVAL_SIGN, OGL_DEFAULT_SWAP_INTERVAL_SIGN_POSITIVE},
{OGL_EVENT_LOG_SEVERITY_THRESHOLD_ID, OGL_EVENT_LOG_SEVERITY_THRESHOLD_STRING, 5, (NvU32 *)g_valuesOGL_EVENT_LOG_SEVERITY_THRESHOLD, OGL_EVENT_LOG_SEVERITY_THRESHOLD_ALL},
{OGL_EXTENSION_STRING_VERSION_ID, OGL_EXTENSION_STRING_VERSION_STRING, 0, NULL, 0x00000000},
{OGL_FORCE_BLIT_ID, OGL_FORCE_BLIT_STRING, 2, (NvU32 *)g_valuesOGL_FORCE_BLIT, OGL_FORCE_BLIT_OFF},
{OGL_FORCE_STEREO_ID, OGL_FORCE_STEREO_STRING, 2, (NvU32 *)g_valuesOGL_FORCE_STEREO, OGL_FORCE_STEREO_OFF},
{OGL_MAX_FRAMES_ALLOWED_ID, OGL_MAX_FRAMES_ALLOWED_STRING, 0, NULL, 0x00000002},
{OGL_OVERLAY_PIXEL_TYPE_ID, OGL_OVERLAY_PIXEL_TYPE_STRING, 4, (NvU32 *)g_valuesOGL_OVERLAY_PIXEL_TYPE, OGL_OVERLAY_PIXEL_TYPE_CI},
{OGL_OVERLAY_SUPPORT_ID, OGL_OVERLAY_SUPPORT_STRING, 3, (NvU32 *)g_valuesOGL_OVERLAY_SUPPORT, OGL_OVERLAY_SUPPORT_OFF},
{OGL_QUALITY_ENHANCEMENTS_ID, OGL_QUALITY_ENHANCEMENTS_STRING, 4, (NvU32 *)g_valuesOGL_QUALITY_ENHANCEMENTS, OGL_QUALITY_ENHANCEMENTS_QUAL},
{OGL_SINGLE_BACKDEPTH_BUFFER_ID, OGL_SINGLE_BACKDEPTH_BUFFER_STRING, 3, (NvU32 *)g_valuesOGL_SINGLE_BACKDEPTH_BUFFER, OGL_SINGLE_BACKDEPTH_BUFFER_DISABLE},
{OGL_SLI_MULTICAST_ID, OGL_SLI_MULTICAST_STRING, 4, (NvU32 *)g_valuesOGL_SLI_MULTICAST, OGL_SLI_MULTICAST_DISABLE},
{OGL_THREAD_CONTROL_ID, OGL_THREAD_CONTROL_STRING, 2, (NvU32 *)g_valuesOGL_THREAD_CONTROL, 0x00000000},
{OGL_TMON_LEVEL_ID, OGL_TMON_LEVEL_STRING, 6, (NvU32 *)g_valuesOGL_TMON_LEVEL, OGL_TMON_LEVEL_MOST},
{OGL_TRIPLE_BUFFER_ID, OGL_TRIPLE_BUFFER_STRING, 2, (NvU32 *)g_valuesOGL_TRIPLE_BUFFER, OGL_TRIPLE_BUFFER_DISABLED},
{AA_BEHAVIOR_FLAGS_ID, AA_BEHAVIOR_FLAGS_STRING, 18, (NvU32 *)g_valuesAA_BEHAVIOR_FLAGS, AA_BEHAVIOR_FLAGS_DEFAULT},
{AA_MODE_ALPHATOCOVERAGE_ID, AA_MODE_ALPHATOCOVERAGE_STRING, 4, (NvU32 *)g_valuesAA_MODE_ALPHATOCOVERAGE, 0x00000000},
{AA_MODE_GAMMACORRECTION_ID, AA_MODE_GAMMACORRECTION_STRING, 8, (NvU32 *)g_valuesAA_MODE_GAMMACORRECTION, 0x00000000},
{AA_MODE_METHOD_ID, AA_MODE_METHOD_STRING, 50, (NvU32 *)g_valuesAA_MODE_METHOD, AA_MODE_METHOD_NONE},
{AA_MODE_REPLAY_ID, AA_MODE_REPLAY_STRING, 20, (NvU32 *)g_valuesAA_MODE_REPLAY, 0x00000000},
{AA_MODE_SELECTOR_ID, AA_MODE_SELECTOR_STRING, 5, (NvU32 *)g_valuesAA_MODE_SELECTOR, AA_MODE_SELECTOR_APP_CONTROL},
{AA_MODE_SELECTOR_SLIAA_ID, AA_MODE_SELECTOR_SLIAA_STRING, 2, (NvU32 *)g_valuesAA_MODE_SELECTOR_SLIAA, AA_MODE_SELECTOR_SLIAA_DISABLED},
{ANISO_MODE_LEVEL_ID, ANISO_MODE_LEVEL_STRING, 5, (NvU32 *)g_valuesANISO_MODE_LEVEL, ANISO_MODE_LEVEL_DEFAULT},
{ANISO_MODE_SELECTOR_ID, ANISO_MODE_SELECTOR_STRING, 6, (NvU32 *)g_valuesANISO_MODE_SELECTOR, ANISO_MODE_SELECTOR_DEFAULT},
{ANSEL_ALLOW_ID, ANSEL_ALLOW_STRING, 2, (NvU32 *)g_valuesANSEL_ALLOW, ANSEL_ALLOW_ALLOWED},
{ANSEL_ALLOWLISTED_ID, ANSEL_ALLOWLISTED_STRING, 2, (NvU32 *)g_valuesANSEL_ALLOWLISTED, ANSEL_ALLOWLISTED_DISALLOWED},
{ANSEL_ENABLE_ID, ANSEL_ENABLE_STRING, 2, (NvU32 *)g_valuesANSEL_ENABLE, ANSEL_ENABLE_ON},
{APPIDLE_DYNAMIC_FRL_FPS_ID, APPIDLE_DYNAMIC_FRL_FPS_STRING, 0, NULL, 0x00000000},
{APPIDLE_DYNAMIC_FRL_THRESHOLD_TIME_ID, APPIDLE_DYNAMIC_FRL_THRESHOLD_TIME_STRING, 0, NULL, 0x00000000},
{APPLICATION_PROFILE_NOTIFICATION_TIMEOUT_ID, APPLICATION_PROFILE_NOTIFICATION_TIMEOUT_STRING, 6, (NvU32 *)g_valuesAPPLICATION_PROFILE_NOTIFICATION_TIMEOUT, APPLICATION_PROFILE_NOTIFICATION_TIMEOUT_DISABLED},
{APPLICATION_STEAM_ID_ID, APPLICATION_STEAM_ID_STRING, 0, NULL, 0x00000000},
{BATTERY_BOOST_APP_FPS_ID, BATTERY_BOOST_APP_FPS_STRING, 3, (NvU32 *)g_valuesBATTERY_BOOST_APP_FPS, BATTERY_BOOST_APP_FPS_NO_OVERRIDE},
{CPL_HIDDEN_PROFILE_ID, CPL_HIDDEN_PROFILE_STRING, 2, (NvU32 *)g_valuesCPL_HIDDEN_PROFILE, CPL_HIDDEN_PROFILE_DISABLED},
{EXPORT_PERF_COUNTERS_ID, EXPORT_PERF_COUNTERS_STRING, 2, (NvU32 *)g_valuesEXPORT_PERF_COUNTERS, EXPORT_PERF_COUNTERS_OFF},
{EXTERNAL_QUIET_MODE_ID, EXTERNAL_QUIET_MODE_STRING, 2, (NvU32 *)g_valuesEXTERNAL_QUIET_MODE, EXTERNAL_QUIET_MODE_OFF},
{FRL_FPS_ID, FRL_FPS_STRING, 3, (NvU32 *)g_valuesFRL_FPS, FRL_FPS_DISABLED},
{FXAA_ALLOW_ID, FXAA_ALLOW_STRING, 2, (NvU32 *)g_valuesFXAA_ALLOW, FXAA_ALLOW_ALLOWED},
{FXAA_ENABLE_ID, FXAA_ENABLE_STRING, 2, (NvU32 *)g_valuesFXAA_ENABLE, FXAA_ENABLE_OFF},
{FXAA_INDICATOR_ENABLE_ID, FXAA_INDICATOR_ENABLE_STRING, 2, (NvU32 *)g_valuesFXAA_INDICATOR_ENABLE, FXAA_INDICATOR_ENABLE_OFF},
{LATENCY_INDICATOR_AUTOALIGN_ID, LATENCY_INDICATOR_AUTOALIGN_STRING, 2, (NvU32 *)g_valuesLATENCY_INDICATOR_AUTOALIGN, LATENCY_INDICATOR_AUTOALIGN_ENABLED},
{MCSFRSHOWSPLIT_ID, MCSFRSHOWSPLIT_STRING, 2, (NvU32 *)g_valuesMCSFRSHOWSPLIT, MCSFRSHOWSPLIT_DISABLED},
{NV_QUALITY_UPSCALING_ID, NV_QUALITY_UPSCALING_STRING, 2, (NvU32 *)g_valuesNV_QUALITY_UPSCALING, NV_QUALITY_UPSCALING_OFF},
{OPTIMUS_MAXAA_ID, OPTIMUS_MAXAA_STRING, 2, (NvU32 *)g_valuesOPTIMUS_MAXAA, 0x00000000},
{PHYSXINDICATOR_ID, PHYSXINDICATOR_STRING, 2, (NvU32 *)g_valuesPHYSXINDICATOR, PHYSXINDICATOR_DISABLED},
{PREFERRED_PSTATE_ID, PREFERRED_PSTATE_STRING, 8, (NvU32 *)g_valuesPREFERRED_PSTATE, PREFERRED_PSTATE_OPTIMAL_POWER},
{PREVENT_UI_AF_OVERRIDE_ID, PREVENT_UI_AF_OVERRIDE_STRING, 2, (NvU32 *)g_valuesPREVENT_UI_AF_OVERRIDE, PREVENT_UI_AF_OVERRIDE_OFF},
{SHIM_MAXRES_ID, SHIM_MAXRES_STRING, 0, NULL, 0x00000000},
{SHIM_MCCOMPAT_ID, SHIM_MCCOMPAT_STRING, 8, (NvU32 *)g_valuesSHIM_MCCOMPAT, SHIM_MCCOMPAT_AUTO_SELECT},
{SHIM_RENDERING_MODE_ID, SHIM_RENDERING_MODE_STRING, 8, (NvU32 *)g_valuesSHIM_RENDERING_MODE, SHIM_RENDERING_MODE_AUTO_SELECT},
{SHIM_RENDERING_OPTIONS_ID, SHIM_RENDERING_OPTIONS_STRING, 30, (NvU32 *)g_valuesSHIM_RENDERING_OPTIONS, 0x00000000},
{SLI_GPU_COUNT_ID, SLI_GPU_COUNT_STRING, 5, (NvU32 *)g_valuesSLI_GPU_COUNT, SLI_GPU_COUNT_AUTOSELECT},
{SLI_PREDEFINED_GPU_COUNT_ID, SLI_PREDEFINED_GPU_COUNT_STRING, 5, (NvU32 *)g_valuesSLI_PREDEFINED_GPU_COUNT, SLI_PREDEFINED_GPU_COUNT_AUTOSELECT},
{SLI_PREDEFINED_GPU_COUNT_DX10_ID, SLI_PREDEFINED_GPU_COUNT_DX10_STRING, 5, (NvU32 *)g_valuesSLI_PREDEFINED_GPU_COUNT_DX10, SLI_PREDEFINED_GPU_COUNT_DX10_AUTOSELECT},
{SLI_PREDEFINED_MODE_ID, SLI_PREDEFINED_MODE_STRING, 6, (NvU32 *)g_valuesSLI_PREDEFINED_MODE, SLI_PREDEFINED_MODE_AUTOSELECT},
{SLI_PREDEFINED_MODE_DX10_ID, SLI_PREDEFINED_MODE_DX10_STRING, 6, (NvU32 *)g_valuesSLI_PREDEFINED_MODE_DX10, SLI_PREDEFINED_MODE_DX10_AUTOSELECT},
{SLI_RENDERING_MODE_ID, SLI_RENDERING_MODE_STRING, 6, (NvU32 *)g_valuesSLI_RENDERING_MODE, SLI_RENDERING_MODE_AUTOSELECT},
{VRPRERENDERLIMIT_ID, VRPRERENDERLIMIT_STRING, 4, (NvU32 *)g_valuesVRPRERENDERLIMIT, VRPRERENDERLIMIT_DEFAULT},
{VRRFEATUREINDICATOR_ID, VRRFEATUREINDICATOR_STRING, 2, (NvU32 *)g_valuesVRRFEATUREINDICATOR, VRRFEATUREINDICATOR_ENABLED},
{VRROVERLAYINDICATOR_ID, VRROVERLAYINDICATOR_STRING, 2, (NvU32 *)g_valuesVRROVERLAYINDICATOR, VRROVERLAYINDICATOR_ENABLED},
{VRRREQUESTSTATE_ID, VRRREQUESTSTATE_STRING, 3, (NvU32 *)g_valuesVRRREQUESTSTATE, VRRREQUESTSTATE_FULLSCREEN_ONLY},
{VRR_APP_OVERRIDE_ID, VRR_APP_OVERRIDE_STRING, 5, (NvU32 *)g_valuesVRR_APP_OVERRIDE, VRR_APP_OVERRIDE_ALLOW},
{VRR_APP_OVERRIDE_REQUEST_STATE_ID, VRR_APP_OVERRIDE_REQUEST_STATE_STRING, 5, (NvU32 *)g_valuesVRR_APP_OVERRIDE_REQUEST_STATE, VRR_APP_OVERRIDE_REQUEST_STATE_ALLOW},
{VRR_MODE_ID, VRR_MODE_STRING, 3, (NvU32 *)g_valuesVRR_MODE, VRR_MODE_FULLSCREEN_ONLY},
{VSYNCSMOOTHAFR_ID, VSYNCSMOOTHAFR_STRING, 2, (NvU32 *)g_valuesVSYNCSMOOTHAFR, VSYNCSMOOTHAFR_OFF},
{VSYNCVRRCONTROL_ID, VSYNCVRRCONTROL_STRING, 3, (NvU32 *)g_valuesVSYNCVRRCONTROL, VSYNCVRRCONTROL_ENABLE},
{VSYNC_BEHAVIOR_FLAGS_ID, VSYNC_BEHAVIOR_FLAGS_STRING, 3, (NvU32 *)g_valuesVSYNC_BEHAVIOR_FLAGS, VSYNC_BEHAVIOR_FLAGS_DEFAULT},
{WKS_API_STEREO_EYES_EXCHANGE_ID, WKS_API_STEREO_EYES_EXCHANGE_STRING, 2, (NvU32 *)g_valuesWKS_API_STEREO_EYES_EXCHANGE, WKS_API_STEREO_EYES_EXCHANGE_OFF},
{WKS_API_STEREO_MODE_ID, WKS_API_STEREO_MODE_STRING, 25, (NvU32 *)g_valuesWKS_API_STEREO_MODE, WKS_API_STEREO_MODE_SHUTTER_GLASSES},
{WKS_STEREO_DONGLE_SUPPORT_ID, WKS_STEREO_DONGLE_SUPPORT_STRING, 3, (NvU32 *)g_valuesWKS_STEREO_DONGLE_SUPPORT, WKS_STEREO_DONGLE_SUPPORT_DAC},
{WKS_STEREO_SUPPORT_ID, WKS_STEREO_SUPPORT_STRING, 2, (NvU32 *)g_valuesWKS_STEREO_SUPPORT, WKS_STEREO_SUPPORT_OFF},
{WKS_STEREO_SWAP_MODE_ID, WKS_STEREO_SWAP_MODE_STRING, 5, (NvU32 *)g_valuesWKS_STEREO_SWAP_MODE, WKS_STEREO_SWAP_MODE_APPLICATION_CONTROL},
{AO_MODE_ID, AO_MODE_STRING, 4, (NvU32 *)g_valuesAO_MODE, AO_MODE_OFF},
{AO_MODE_ACTIVE_ID, AO_MODE_ACTIVE_STRING, 2, (NvU32 *)g_valuesAO_MODE_ACTIVE, AO_MODE_ACTIVE_DISABLED},
{AUTO_LODBIASADJUST_ID, AUTO_LODBIASADJUST_STRING, 2, (NvU32 *)g_valuesAUTO_LODBIASADJUST, AUTO_LODBIASADJUST_ON},
{EXPORT_PERF_COUNTERS_DX9_ONLY_ID, EXPORT_PERF_COUNTERS_DX9_ONLY_STRING, 2, (NvU32 *)g_valuesEXPORT_PERF_COUNTERS_DX9_ONLY, EXPORT_PERF_COUNTERS_DX9_ONLY_OFF},
{LODBIASADJUST_ID, LODBIASADJUST_STRING, 2, (NvU32 *)g_valuesLODBIASADJUST, 0x00000000},
{MAXWELL_B_SAMPLE_INTERLEAVE_ID, MAXWELL_B_SAMPLE_INTERLEAVE_STRING, 2, (NvU32 *)g_valuesMAXWELL_B_SAMPLE_INTERLEAVE, MAXWELL_B_SAMPLE_INTERLEAVE_OFF},
{PRERENDERLIMIT_ID, PRERENDERLIMIT_STRING, 3, (NvU32 *)g_valuesPRERENDERLIMIT, PRERENDERLIMIT_APP_CONTROLLED},
{PS_SHADERDISKCACHE_ID, PS_SHADERDISKCACHE_STRING, 2, (NvU32 *)g_valuesPS_SHADERDISKCACHE, PS_SHADERDISKCACHE_ON},
{PS_SHADERDISKCACHE_MAX_SIZE_ID, PS_SHADERDISKCACHE_MAX_SIZE_STRING, 2, (NvU32 *)g_valuesPS_SHADERDISKCACHE_MAX_SIZE, 0x00000000},
{PS_TEXFILTER_ANISO_OPTS2_ID, PS_TEXFILTER_ANISO_OPTS2_STRING, 2, (NvU32 *)g_valuesPS_TEXFILTER_ANISO_OPTS2, PS_TEXFILTER_ANISO_OPTS2_OFF},
{PS_TEXFILTER_BILINEAR_IN_ANISO_ID, PS_TEXFILTER_BILINEAR_IN_ANISO_STRING, 2, (NvU32 *)g_valuesPS_TEXFILTER_BILINEAR_IN_ANISO, PS_TEXFILTER_BILINEAR_IN_ANISO_OFF},
{PS_TEXFILTER_DISABLE_TRILIN_SLOPE_ID, PS_TEXFILTER_DISABLE_TRILIN_SLOPE_STRING, 2, (NvU32 *)g_valuesPS_TEXFILTER_DISABLE_TRILIN_SLOPE, PS_TEXFILTER_DISABLE_TRILIN_SLOPE_OFF},
{PS_TEXFILTER_NO_NEG_LODBIAS_ID, PS_TEXFILTER_NO_NEG_LODBIAS_STRING, 2, (NvU32 *)g_valuesPS_TEXFILTER_NO_NEG_LODBIAS, PS_TEXFILTER_NO_NEG_LODBIAS_OFF},
{QUALITY_ENHANCEMENTS_ID, QUALITY_ENHANCEMENTS_STRING, 4, (NvU32 *)g_valuesQUALITY_ENHANCEMENTS, QUALITY_ENHANCEMENTS_QUALITY},
{QUALITY_ENHANCEMENT_SUBSTITUTION_ID, QUALITY_ENHANCEMENT_SUBSTITUTION_STRING, 2, (NvU32 *)g_valuesQUALITY_ENHANCEMENT_SUBSTITUTION, QUALITY_ENHANCEMENT_SUBSTITUTION_NO_SUBSTITUTION},
{REFRESH_RATE_OVERRIDE_ID, REFRESH_RATE_OVERRIDE_STRING, 3, (NvU32 *)g_valuesREFRESH_RATE_OVERRIDE, REFRESH_RATE_OVERRIDE_APPLICATION_CONTROLLED},
{SET_POWER_THROTTLE_FOR_PCIe_COMPLIANCE_ID, SET_POWER_THROTTLE_FOR_PCIe_COMPLIANCE_STRING, 2, (NvU32 *)g_valuesSET_POWER_THROTTLE_FOR_PCIe_COMPLIANCE, SET_POWER_THROTTLE_FOR_PCIe_COMPLIANCE_OFF},
{SET_VAB_DATA_ID, SET_VAB_DATA_STRING, 6, (NvU32 *)g_valuesSET_VAB_DATA, SET_VAB_DATA_USE_API_DEFAULTS},
{VSYNCMODE_ID, VSYNCMODE_STRING, 7, (NvU32 *)g_valuesVSYNCMODE, VSYNCMODE_PASSIVE},
{VSYNCTEARCONTROL_ID, VSYNCTEARCONTROL_STRING, 2, (NvU32 *)g_valuesVSYNCTEARCONTROL, VSYNCTEARCONTROL_DISABLE},
};
SettingWSTRINGNameString mapSettingWSTRING[TOTAL_WSTRING_SETTING_NUM] =
{
{OGL_IMPLICIT_GPU_AFFINITY_ID, OGL_IMPLICIT_GPU_AFFINITY_STRING, 1, (const wchar_t **)g_valuesOGL_IMPLICIT_GPU_AFFINITY, L"autoselect"},
{CUDA_EXCLUDED_GPUS_ID, CUDA_EXCLUDED_GPUS_STRING, 1, (const wchar_t **)g_valuesCUDA_EXCLUDED_GPUS, L"none"},
{D3DOGL_GPU_MAX_POWER_ID, D3DOGL_GPU_MAX_POWER_STRING, 1, (const wchar_t **)g_valuesD3DOGL_GPU_MAX_POWER, L"0"},
{ICAFE_LOGO_CONFIG_ID, ICAFE_LOGO_CONFIG_STRING, 0, NULL, L""},
{PS_SHADERDISKCACHE_DLL_PATH_WCHAR_ID, PS_SHADERDISKCACHE_DLL_PATH_WCHAR_STRING, 0, NULL, L""},
};

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,758 @@
/*********************************************************************************************************\
|* *|
|* SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. *|
|* SPDX-License-Identifier: MIT *|
|* *|
|* 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. *|
|* *|
|* *|
\*********************************************************************************************************/
////////////////////////// NVIDIA SHADER EXTENSIONS /////////////////
// internal functions
// Functions in this file are not expected to be called by apps directly
#include "imports/nvapi/nvShaderExtnEnums.h"
struct NvShaderExtnStruct
{
uint opcode; // opcode
uint rid; // resource ID
uint sid; // sampler ID
uint4 dst1u; // destination operand 1 (for instructions that need extra destination operands)
uint4 src3u; // source operand 3
uint4 src4u; // source operand 4
uint4 src5u; // source operand 5
uint4 src0u; // uint source operand 0
uint4 src1u; // uint source operand 0
uint4 src2u; // uint source operand 0
uint4 dst0u; // uint destination operand
uint markUavRef; // the next store to UAV is fake and is used only to identify the uav slot
uint numOutputsForIncCounter; // Used for output to IncrementCounter
float padding1[27]; // struct size: 256 bytes
};
// RW structured buffer for Nvidia shader extensions
// Application needs to define NV_SHADER_EXTN_SLOT as a unused slot, which should be
// set using NvAPI_D3D11_SetNvShaderExtnSlot() call before creating the first shader that
// uses nvidia shader extensions. E.g before including this file in shader define it as:
// #define NV_SHADER_EXTN_SLOT u7
// For SM5.1, application needs to define NV_SHADER_EXTN_REGISTER_SPACE as register space
// E.g. before including this file in shader define it as:
// #define NV_SHADER_EXTN_REGISTER_SPACE space2
// Note that other operations to this UAV will be ignored so application
// should bind a null resource
#ifdef NV_SHADER_EXTN_REGISTER_SPACE
RWStructuredBuffer<NvShaderExtnStruct> g_NvidiaExt : register( NV_SHADER_EXTN_SLOT, NV_SHADER_EXTN_REGISTER_SPACE );
#else
RWStructuredBuffer<NvShaderExtnStruct> g_NvidiaExt : register( NV_SHADER_EXTN_SLOT );
#endif
//----------------------------------------------------------------------------//
// the exposed SHFL instructions accept a mask parameter in src2
// To compute lane mask from width of segment:
// minLaneID : currentLaneId & src2[12:8]
// maxLaneID : minLaneId | (src2[4:0] & ~src2[12:8])
// where [minLaneId, maxLaneId] defines the segment where currentLaneId belongs
// we always set src2[4:0] to 11111 (0x1F), and set src2[12:8] as (32 - width)
int __NvGetShflMaskFromWidth(uint width)
{
return ((NV_WARP_SIZE - width) << 8) | 0x1F;
}
//----------------------------------------------------------------------------//
void __NvReferenceUAVForOp(RWByteAddressBuffer uav)
{
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].markUavRef = 1;
uav.Store(index, 0);
}
void __NvReferenceUAVForOp(RWTexture1D<float2> uav)
{
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].markUavRef = 1;
uav[index] = float2(0,0);
}
void __NvReferenceUAVForOp(RWTexture2D<float2> uav)
{
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].markUavRef = 1;
uav[uint2(index,index)] = float2(0,0);
}
void __NvReferenceUAVForOp(RWTexture3D<float2> uav)
{
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].markUavRef = 1;
uav[uint3(index,index,index)] = float2(0,0);
}
void __NvReferenceUAVForOp(RWTexture1D<float4> uav)
{
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].markUavRef = 1;
uav[index] = float4(0,0,0,0);
}
void __NvReferenceUAVForOp(RWTexture2D<float4> uav)
{
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].markUavRef = 1;
uav[uint2(index,index)] = float4(0,0,0,0);
}
void __NvReferenceUAVForOp(RWTexture3D<float4> uav)
{
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].markUavRef = 1;
uav[uint3(index,index,index)] = float4(0,0,0,0);
}
void __NvReferenceUAVForOp(RWTexture1D<float> uav)
{
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].markUavRef = 1;
uav[index] = 0.0f;
}
void __NvReferenceUAVForOp(RWTexture2D<float> uav)
{
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].markUavRef = 1;
uav[uint2(index,index)] = 0.0f;
}
void __NvReferenceUAVForOp(RWTexture3D<float> uav)
{
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].markUavRef = 1;
uav[uint3(index,index,index)] = 0.0f;
}
void __NvReferenceUAVForOp(RWTexture1D<uint2> uav)
{
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].markUavRef = 1;
uav[index] = uint2(0,0);
}
void __NvReferenceUAVForOp(RWTexture2D<uint2> uav)
{
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].markUavRef = 1;
uav[uint2(index,index)] = uint2(0,0);
}
void __NvReferenceUAVForOp(RWTexture3D<uint2> uav)
{
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].markUavRef = 1;
uav[uint3(index,index,index)] = uint2(0,0);
}
void __NvReferenceUAVForOp(RWTexture1D<uint4> uav)
{
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].markUavRef = 1;
uav[index] = uint4(0,0,0,0);
}
void __NvReferenceUAVForOp(RWTexture2D<uint4> uav)
{
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].markUavRef = 1;
uav[uint2(index,index)] = uint4(0,0,0,0);
}
void __NvReferenceUAVForOp(RWTexture3D<uint4> uav)
{
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].markUavRef = 1;
uav[uint3(index,index,index)] = uint4(0,0,0,0);
}
void __NvReferenceUAVForOp(RWTexture1D<uint> uav)
{
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].markUavRef = 1;
uav[index] = 0;
}
void __NvReferenceUAVForOp(RWTexture2D<uint> uav)
{
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].markUavRef = 1;
uav[uint2(index,index)] = 0;
}
void __NvReferenceUAVForOp(RWTexture3D<uint> uav)
{
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].markUavRef = 1;
uav[uint3(index,index,index)] = 0;
}
void __NvReferenceUAVForOp(RWTexture1D<int2> uav)
{
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].markUavRef = 1;
uav[index] = int2(0,0);
}
void __NvReferenceUAVForOp(RWTexture2D<int2> uav)
{
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].markUavRef = 1;
uav[uint2(index,index)] = int2(0,0);
}
void __NvReferenceUAVForOp(RWTexture3D<int2> uav)
{
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].markUavRef = 1;
uav[uint3(index,index,index)] = int2(0,0);
}
void __NvReferenceUAVForOp(RWTexture1D<int4> uav)
{
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].markUavRef = 1;
uav[index] = int4(0,0,0,0);
}
void __NvReferenceUAVForOp(RWTexture2D<int4> uav)
{
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].markUavRef = 1;
uav[uint2(index,index)] = int4(0,0,0,0);
}
void __NvReferenceUAVForOp(RWTexture3D<int4> uav)
{
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].markUavRef = 1;
uav[uint3(index,index,index)] = int4(0,0,0,0);
}
void __NvReferenceUAVForOp(RWTexture1D<int> uav)
{
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].markUavRef = 1;
uav[index] = 0;
}
void __NvReferenceUAVForOp(RWTexture2D<int> uav)
{
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].markUavRef = 1;
uav[uint2(index,index)] = 0;
}
void __NvReferenceUAVForOp(RWTexture3D<int> uav)
{
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].markUavRef = 1;
uav[uint3(index,index,index)] = 0;
}
//----------------------------------------------------------------------------//
// ATOMIC op sub-opcodes
#define NV_EXTN_ATOM_AND 0
#define NV_EXTN_ATOM_OR 1
#define NV_EXTN_ATOM_XOR 2
#define NV_EXTN_ATOM_ADD 3
#define NV_EXTN_ATOM_MAX 6
#define NV_EXTN_ATOM_MIN 7
#define NV_EXTN_ATOM_SWAP 8
#define NV_EXTN_ATOM_CAS 9
//----------------------------------------------------------------------------//
// performs Atomic operation on two consecutive fp16 values in the given UAV
// the uint paramater 'fp16x2Val' is treated as two fp16 values
// the passed sub-opcode 'op' should be an immediate constant
// byteAddress must be multiple of 4
// the returned value are the two fp16 values packed into a single uint
uint __NvAtomicOpFP16x2(RWByteAddressBuffer uav, uint byteAddress, uint fp16x2Val, uint atomicOpType)
{
__NvReferenceUAVForOp(uav);
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].src0u.x = byteAddress;
g_NvidiaExt[index].src1u.x = fp16x2Val;
g_NvidiaExt[index].src2u.x = atomicOpType;
g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC;
return g_NvidiaExt[index].dst0u.x;
}
//----------------------------------------------------------------------------//
// performs Atomic operation on a R16G16_FLOAT UAV at the given address
// the uint paramater 'fp16x2Val' is treated as two fp16 values
// the passed sub-opcode 'op' should be an immediate constant
// the returned value are the two fp16 values (.x and .y components) packed into a single uint
// Warning: Behaviour of these set of functions is undefined if the UAV is not
// of R16G16_FLOAT format (might result in app crash or TDR)
uint __NvAtomicOpFP16x2(RWTexture1D<float2> uav, uint address, uint fp16x2Val, uint atomicOpType)
{
__NvReferenceUAVForOp(uav);
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].src0u.x = address;
g_NvidiaExt[index].src1u.x = fp16x2Val;
g_NvidiaExt[index].src2u.x = atomicOpType;
g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC;
return g_NvidiaExt[index].dst0u.x;
}
uint __NvAtomicOpFP16x2(RWTexture2D<float2> uav, uint2 address, uint fp16x2Val, uint atomicOpType)
{
__NvReferenceUAVForOp(uav);
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].src0u.xy = address;
g_NvidiaExt[index].src1u.x = fp16x2Val;
g_NvidiaExt[index].src2u.x = atomicOpType;
g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC;
return g_NvidiaExt[index].dst0u.x;
}
uint __NvAtomicOpFP16x2(RWTexture3D<float2> uav, uint3 address, uint fp16x2Val, uint atomicOpType)
{
__NvReferenceUAVForOp(uav);
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].src0u.xyz = address;
g_NvidiaExt[index].src1u.x = fp16x2Val;
g_NvidiaExt[index].src2u.x = atomicOpType;
g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC;
return g_NvidiaExt[index].dst0u.x;
}
//----------------------------------------------------------------------------//
// performs Atomic operation on a R16G16B16A16_FLOAT UAV at the given address
// the uint2 paramater 'fp16x2Val' is treated as four fp16 values
// i.e, fp16x2Val.x = uav.xy and fp16x2Val.y = uav.yz
// the passed sub-opcode 'op' should be an immediate constant
// the returned value are the four fp16 values (.xyzw components) packed into uint2
// Warning: Behaviour of these set of functions is undefined if the UAV is not
// of R16G16B16A16_FLOAT format (might result in app crash or TDR)
uint2 __NvAtomicOpFP16x2(RWTexture1D<float4> uav, uint address, uint2 fp16x2Val, uint atomicOpType)
{
__NvReferenceUAVForOp(uav);
// break it down into two fp16x2 atomic ops
uint2 retVal;
// first op has x-coordinate = x * 2
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].src0u.x = address * 2;
g_NvidiaExt[index].src1u.x = fp16x2Val.x;
g_NvidiaExt[index].src2u.x = atomicOpType;
g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC;
retVal.x = g_NvidiaExt[index].dst0u.x;
// second op has x-coordinate = x * 2 + 1
index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].src0u.x = address * 2 + 1;
g_NvidiaExt[index].src1u.x = fp16x2Val.y;
g_NvidiaExt[index].src2u.x = atomicOpType;
g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC;
retVal.y = g_NvidiaExt[index].dst0u.x;
return retVal;
}
uint2 __NvAtomicOpFP16x2(RWTexture2D<float4> uav, uint2 address, uint2 fp16x2Val, uint atomicOpType)
{
__NvReferenceUAVForOp(uav);
// break it down into two fp16x2 atomic ops
uint2 retVal;
// first op has x-coordinate = x * 2
uint2 addressTemp = uint2(address.x * 2, address.y);
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].src0u.xy = addressTemp;
g_NvidiaExt[index].src1u.x = fp16x2Val.x;
g_NvidiaExt[index].src2u.x = atomicOpType;
g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC;
retVal.x = g_NvidiaExt[index].dst0u.x;
// second op has x-coordinate = x * 2 + 1
addressTemp.x++;
index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].src0u.xy = addressTemp;
g_NvidiaExt[index].src1u.x = fp16x2Val.y;
g_NvidiaExt[index].src2u.x = atomicOpType;
g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC;
retVal.y = g_NvidiaExt[index].dst0u.x;
return retVal;
}
uint2 __NvAtomicOpFP16x2(RWTexture3D<float4> uav, uint3 address, uint2 fp16x2Val, uint atomicOpType)
{
__NvReferenceUAVForOp(uav);
// break it down into two fp16x2 atomic ops
uint2 retVal;
// first op has x-coordinate = x * 2
uint3 addressTemp = uint3(address.x * 2, address.y, address.z);
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].src0u.xyz = addressTemp;
g_NvidiaExt[index].src1u.x = fp16x2Val.x;
g_NvidiaExt[index].src2u.x = atomicOpType;
g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC;
retVal.x = g_NvidiaExt[index].dst0u.x;
// second op has x-coordinate = x * 2 + 1
addressTemp.x++;
index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].src0u.xyz = addressTemp;
g_NvidiaExt[index].src1u.x = fp16x2Val.y;
g_NvidiaExt[index].src2u.x = atomicOpType;
g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC;
retVal.y = g_NvidiaExt[index].dst0u.x;
return retVal;
}
uint __fp32x2Tofp16x2(float2 val)
{
return (f32tof16(val.y)<<16) | f32tof16(val.x) ;
}
uint2 __fp32x4Tofp16x4(float4 val)
{
return uint2( (f32tof16(val.y)<<16) | f32tof16(val.x), (f32tof16(val.w)<<16) | f32tof16(val.z) ) ;
}
//----------------------------------------------------------------------------//
// FP32 Atomic functions
// performs Atomic operation treating the uav as float (fp32) values
// the passed sub-opcode 'op' should be an immediate constant
// byteAddress must be multiple of 4
float __NvAtomicAddFP32(RWByteAddressBuffer uav, uint byteAddress, float val)
{
__NvReferenceUAVForOp(uav);
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].src0u.x = byteAddress;
g_NvidiaExt[index].src1u.x = asuint(val); // passing as uint to make it more convinient for the driver to translate
g_NvidiaExt[index].src2u.x = NV_EXTN_ATOM_ADD;
g_NvidiaExt[index].opcode = NV_EXTN_OP_FP32_ATOMIC;
return asfloat(g_NvidiaExt[index].dst0u.x);
}
float __NvAtomicAddFP32(RWTexture1D<float> uav, uint address, float val)
{
__NvReferenceUAVForOp(uav);
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].src0u.x = address;
g_NvidiaExt[index].src1u.x = asuint(val);
g_NvidiaExt[index].src2u.x = NV_EXTN_ATOM_ADD;
g_NvidiaExt[index].opcode = NV_EXTN_OP_FP32_ATOMIC;
return asfloat(g_NvidiaExt[index].dst0u.x);
}
float __NvAtomicAddFP32(RWTexture2D<float> uav, uint2 address, float val)
{
__NvReferenceUAVForOp(uav);
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].src0u.xy = address;
g_NvidiaExt[index].src1u.x = asuint(val);
g_NvidiaExt[index].src2u.x = NV_EXTN_ATOM_ADD;
g_NvidiaExt[index].opcode = NV_EXTN_OP_FP32_ATOMIC;
return asfloat(g_NvidiaExt[index].dst0u.x);
}
float __NvAtomicAddFP32(RWTexture3D<float> uav, uint3 address, float val)
{
__NvReferenceUAVForOp(uav);
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].src0u.xyz = address;
g_NvidiaExt[index].src1u.x = asuint(val);
g_NvidiaExt[index].src2u.x = NV_EXTN_ATOM_ADD;
g_NvidiaExt[index].opcode = NV_EXTN_OP_FP32_ATOMIC;
return asfloat(g_NvidiaExt[index].dst0u.x);
}
//----------------------------------------------------------------------------//
// UINT64 Atmoic Functions
// The functions below performs atomic operation on the given UAV treating the value as uint64
// byteAddress must be multiple of 8
// The returned value is the value present in memory location before the atomic operation
// uint2 vector type is used to represent a single uint64 value with the x component containing the low 32 bits and y component the high 32 bits.
uint2 __NvAtomicCompareExchangeUINT64(RWByteAddressBuffer uav, uint byteAddress, uint2 compareValue, uint2 value)
{
__NvReferenceUAVForOp(uav);
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].src0u.x = byteAddress;
g_NvidiaExt[index].src1u.xy = compareValue;
g_NvidiaExt[index].src1u.zw = value;
g_NvidiaExt[index].src2u.x = NV_EXTN_ATOM_CAS;
g_NvidiaExt[index].opcode = NV_EXTN_OP_UINT64_ATOMIC;
return g_NvidiaExt[index].dst0u.xy;
}
uint2 __NvAtomicOpUINT64(RWByteAddressBuffer uav, uint byteAddress, uint2 value, uint atomicOpType)
{
__NvReferenceUAVForOp(uav);
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].src0u.x = byteAddress;
g_NvidiaExt[index].src1u.xy = value;
g_NvidiaExt[index].src2u.x = atomicOpType;
g_NvidiaExt[index].opcode = NV_EXTN_OP_UINT64_ATOMIC;
return g_NvidiaExt[index].dst0u.xy;
}
uint2 __NvAtomicCompareExchangeUINT64(RWTexture1D<uint2> uav, uint address, uint2 compareValue, uint2 value)
{
__NvReferenceUAVForOp(uav);
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].src0u.x = address;
g_NvidiaExt[index].src1u.xy = compareValue;
g_NvidiaExt[index].src1u.zw = value;
g_NvidiaExt[index].src2u.x = NV_EXTN_ATOM_CAS;
g_NvidiaExt[index].opcode = NV_EXTN_OP_UINT64_ATOMIC;
return g_NvidiaExt[index].dst0u.xy;
}
uint2 __NvAtomicOpUINT64(RWTexture1D<uint2> uav, uint address, uint2 value, uint atomicOpType)
{
__NvReferenceUAVForOp(uav);
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].src0u.x = address;
g_NvidiaExt[index].src1u.xy = value;
g_NvidiaExt[index].src2u.x = atomicOpType;
g_NvidiaExt[index].opcode = NV_EXTN_OP_UINT64_ATOMIC;
return g_NvidiaExt[index].dst0u.xy;
}
uint2 __NvAtomicCompareExchangeUINT64(RWTexture2D<uint2> uav, uint2 address, uint2 compareValue, uint2 value)
{
__NvReferenceUAVForOp(uav);
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].src0u.xy = address;
g_NvidiaExt[index].src1u.xy = compareValue;
g_NvidiaExt[index].src1u.zw = value;
g_NvidiaExt[index].src2u.x = NV_EXTN_ATOM_CAS;
g_NvidiaExt[index].opcode = NV_EXTN_OP_UINT64_ATOMIC;
return g_NvidiaExt[index].dst0u.xy;
}
uint2 __NvAtomicOpUINT64(RWTexture2D<uint2> uav, uint2 address, uint2 value, uint atomicOpType)
{
__NvReferenceUAVForOp(uav);
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].src0u.xy = address;
g_NvidiaExt[index].src1u.xy = value;
g_NvidiaExt[index].src2u.x = atomicOpType;
g_NvidiaExt[index].opcode = NV_EXTN_OP_UINT64_ATOMIC;
return g_NvidiaExt[index].dst0u.xy;
}
uint2 __NvAtomicCompareExchangeUINT64(RWTexture3D<uint2> uav, uint3 address, uint2 compareValue, uint2 value)
{
__NvReferenceUAVForOp(uav);
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].src0u.xyz = address;
g_NvidiaExt[index].src1u.xy = compareValue;
g_NvidiaExt[index].src1u.zw = value;
g_NvidiaExt[index].src2u.x = NV_EXTN_ATOM_CAS;
g_NvidiaExt[index].opcode = NV_EXTN_OP_UINT64_ATOMIC;
return g_NvidiaExt[index].dst0u.xy;
}
uint2 __NvAtomicOpUINT64(RWTexture3D<uint2> uav, uint3 address, uint2 value, uint atomicOpType)
{
__NvReferenceUAVForOp(uav);
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].src0u.xyz = address;
g_NvidiaExt[index].src1u.xy = value;
g_NvidiaExt[index].src2u.x = atomicOpType;
g_NvidiaExt[index].opcode = NV_EXTN_OP_UINT64_ATOMIC;
return g_NvidiaExt[index].dst0u.xy;
}
uint4 __NvFootprint(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint footprintmode, uint gran, int3 offset = int3(0, 0, 0))
{
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].src0u.x = texIndex;
g_NvidiaExt[index].src0u.y = smpIndex;
g_NvidiaExt[index].src1u.xyz = asuint(location);
g_NvidiaExt[index].src1u.w = gran;
g_NvidiaExt[index].src3u.x = texSpace;
g_NvidiaExt[index].src3u.y = smpSpace;
g_NvidiaExt[index].src3u.z = texType;
g_NvidiaExt[index].src3u.w = footprintmode;
g_NvidiaExt[index].src4u.xyz = asuint(offset);
g_NvidiaExt[index].opcode = NV_EXTN_OP_FOOTPRINT;
g_NvidiaExt[index].numOutputsForIncCounter = 4;
// result is returned as the return value of IncrementCounter on fake UAV slot
uint4 op;
op.x = g_NvidiaExt.IncrementCounter();
op.y = g_NvidiaExt.IncrementCounter();
op.z = g_NvidiaExt.IncrementCounter();
op.w = g_NvidiaExt.IncrementCounter();
return op;
}
uint4 __NvFootprintBias(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint footprintmode, uint gran, float bias, int3 offset = int3(0, 0, 0))
{
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].src0u.x = texIndex;
g_NvidiaExt[index].src0u.y = smpIndex;
g_NvidiaExt[index].src1u.xyz = asuint(location);
g_NvidiaExt[index].src1u.w = gran;
g_NvidiaExt[index].src2u.x = asuint(bias);
g_NvidiaExt[index].src3u.x = texSpace;
g_NvidiaExt[index].src3u.y = smpSpace;
g_NvidiaExt[index].src3u.z = texType;
g_NvidiaExt[index].src3u.w = footprintmode;
g_NvidiaExt[index].src4u.xyz = asuint(offset);
g_NvidiaExt[index].opcode = NV_EXTN_OP_FOOTPRINT_BIAS;
g_NvidiaExt[index].numOutputsForIncCounter = 4;
// result is returned as the return value of IncrementCounter on fake UAV slot
uint4 op;
op.x = g_NvidiaExt.IncrementCounter();
op.y = g_NvidiaExt.IncrementCounter();
op.z = g_NvidiaExt.IncrementCounter();
op.w = g_NvidiaExt.IncrementCounter();
return op;
}
uint4 __NvFootprintLevel(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint footprintmode, uint gran, float lodLevel, int3 offset = int3(0, 0, 0))
{
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].src0u.x = texIndex;
g_NvidiaExt[index].src0u.y = smpIndex;
g_NvidiaExt[index].src1u.xyz = asuint(location);
g_NvidiaExt[index].src1u.w = gran;
g_NvidiaExt[index].src2u.x = asuint(lodLevel);
g_NvidiaExt[index].src3u.x = texSpace;
g_NvidiaExt[index].src3u.y = smpSpace;
g_NvidiaExt[index].src3u.z = texType;
g_NvidiaExt[index].src3u.w = footprintmode;
g_NvidiaExt[index].src4u.xyz = asuint(offset);
g_NvidiaExt[index].opcode = NV_EXTN_OP_FOOTPRINT_LEVEL;
g_NvidiaExt[index].numOutputsForIncCounter = 4;
// result is returned as the return value of IncrementCounter on fake UAV slot
uint4 op;
op.x = g_NvidiaExt.IncrementCounter();
op.y = g_NvidiaExt.IncrementCounter();
op.z = g_NvidiaExt.IncrementCounter();
op.w = g_NvidiaExt.IncrementCounter();
return op;
}
uint4 __NvFootprintGrad(uint texSpace, uint texIndex, uint smpSpace, uint smpIndex, uint texType, float3 location, uint footprintmode, uint gran, float3 ddx, float3 ddy, int3 offset = int3(0, 0, 0))
{
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].src0u.x = texIndex;
g_NvidiaExt[index].src0u.y = smpIndex;
g_NvidiaExt[index].src1u.xyz = asuint(location);
g_NvidiaExt[index].src1u.w = gran;
g_NvidiaExt[index].src2u.xyz = asuint(ddx);
g_NvidiaExt[index].src5u.xyz = asuint(ddy);
g_NvidiaExt[index].src3u.x = texSpace;
g_NvidiaExt[index].src3u.y = smpSpace;
g_NvidiaExt[index].src3u.z = texType;
g_NvidiaExt[index].src3u.w = footprintmode;
g_NvidiaExt[index].src4u.xyz = asuint(offset);
g_NvidiaExt[index].opcode = NV_EXTN_OP_FOOTPRINT_GRAD;
g_NvidiaExt[index].numOutputsForIncCounter = 4;
// result is returned as the return value of IncrementCounter on fake UAV slot
uint4 op;
op.x = g_NvidiaExt.IncrementCounter();
op.y = g_NvidiaExt.IncrementCounter();
op.z = g_NvidiaExt.IncrementCounter();
op.w = g_NvidiaExt.IncrementCounter();
return op;
}
// returns value of special register - specify subopcode from any of NV_SPECIALOP_* specified in nvShaderExtnEnums.h - other opcodes undefined behavior
uint __NvGetSpecial(uint subOpCode)
{
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].opcode = NV_EXTN_OP_GET_SPECIAL;
g_NvidiaExt[index].src0u.x = subOpCode;
return g_NvidiaExt.IncrementCounter();
}
// predicate is returned in laneValid indicating if srcLane is in range and val from specified lane is returned.
int __NvShflGeneric(int val, uint srcLane, uint maskClampVal, out uint laneValid)
{
uint index = g_NvidiaExt.IncrementCounter();
g_NvidiaExt[index].src0u.x = val; // variable to be shuffled
g_NvidiaExt[index].src0u.y = srcLane; // source lane
g_NvidiaExt[index].src0u.z = maskClampVal;
g_NvidiaExt[index].opcode = NV_EXTN_OP_SHFL_GENERIC;
g_NvidiaExt[index].numOutputsForIncCounter = 2;
laneValid = asuint(g_NvidiaExt.IncrementCounter());
return g_NvidiaExt.IncrementCounter();
}

View File

@@ -0,0 +1,142 @@
/*********************************************************************************************************\
|* *|
|* SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. *|
|* SPDX-License-Identifier: MIT *|
|* *|
|* 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. *|
|* *|
|* *|
\*********************************************************************************************************/
////////////////////////////////////////////////////////////////////////////////
////////////////////////// NVIDIA SHADER EXTENSIONS ////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// This file can be included both from HLSL shader code as well as C++ code.
// The app should call NvAPI_D3D11_IsNvShaderExtnOpCodeSupported() / NvAPI_D3D12_IsNvShaderExtnOpCodeSupported()
// to check for support for every nv shader extension opcode it plans to use
//----------------------------------------------------------------------------//
//---------------------------- NV Shader Extn Version -----------------------//
//----------------------------------------------------------------------------//
#define NV_SHADER_EXTN_VERSION 1
//----------------------------------------------------------------------------//
//---------------------------- Misc constants --------------------------------//
//----------------------------------------------------------------------------//
#define NV_WARP_SIZE 32
#define NV_WARP_SIZE_LOG2 5
//----------------------------------------------------------------------------//
//---------------------------- opCode constants ------------------------------//
//----------------------------------------------------------------------------//
#define NV_EXTN_OP_SHFL 1
#define NV_EXTN_OP_SHFL_UP 2
#define NV_EXTN_OP_SHFL_DOWN 3
#define NV_EXTN_OP_SHFL_XOR 4
#define NV_EXTN_OP_VOTE_ALL 5
#define NV_EXTN_OP_VOTE_ANY 6
#define NV_EXTN_OP_VOTE_BALLOT 7
#define NV_EXTN_OP_GET_LANE_ID 8
#define NV_EXTN_OP_FP16_ATOMIC 12
#define NV_EXTN_OP_FP32_ATOMIC 13
#define NV_EXTN_OP_GET_SPECIAL 19
#define NV_EXTN_OP_UINT64_ATOMIC 20
#define NV_EXTN_OP_MATCH_ANY 21
// FOOTPRINT - For Sample and SampleBias
#define NV_EXTN_OP_FOOTPRINT 28
#define NV_EXTN_OP_FOOTPRINT_BIAS 29
#define NV_EXTN_OP_GET_SHADING_RATE 30
// FOOTPRINT - For SampleLevel and SampleGrad
#define NV_EXTN_OP_FOOTPRINT_LEVEL 31
#define NV_EXTN_OP_FOOTPRINT_GRAD 32
// SHFL Generic
#define NV_EXTN_OP_SHFL_GENERIC 33
#define NV_EXTN_OP_VPRS_EVAL_ATTRIB_AT_SAMPLE 51
#define NV_EXTN_OP_VPRS_EVAL_ATTRIB_SNAPPED 52
// HitObject API
#define NV_EXTN_OP_HIT_OBJECT_TRACE_RAY 67
#define NV_EXTN_OP_HIT_OBJECT_MAKE_HIT 68
#define NV_EXTN_OP_HIT_OBJECT_MAKE_HIT_WITH_RECORD_INDEX 69
#define NV_EXTN_OP_HIT_OBJECT_MAKE_MISS 70
#define NV_EXTN_OP_HIT_OBJECT_REORDER_THREAD 71
#define NV_EXTN_OP_HIT_OBJECT_INVOKE 72
#define NV_EXTN_OP_HIT_OBJECT_IS_MISS 73
#define NV_EXTN_OP_HIT_OBJECT_GET_INSTANCE_ID 74
#define NV_EXTN_OP_HIT_OBJECT_GET_INSTANCE_INDEX 75
#define NV_EXTN_OP_HIT_OBJECT_GET_PRIMITIVE_INDEX 76
#define NV_EXTN_OP_HIT_OBJECT_GET_GEOMETRY_INDEX 77
#define NV_EXTN_OP_HIT_OBJECT_GET_HIT_KIND 78
#define NV_EXTN_OP_HIT_OBJECT_GET_RAY_DESC 79
#define NV_EXTN_OP_HIT_OBJECT_GET_ATTRIBUTES 80
#define NV_EXTN_OP_HIT_OBJECT_GET_SHADER_TABLE_INDEX 81
#define NV_EXTN_OP_HIT_OBJECT_LOAD_LOCAL_ROOT_TABLE_CONSTANT 82
#define NV_EXTN_OP_HIT_OBJECT_IS_HIT 83
#define NV_EXTN_OP_HIT_OBJECT_IS_NOP 84
#define NV_EXTN_OP_HIT_OBJECT_MAKE_NOP 85
// Micro-map API
#define NV_EXTN_OP_RT_TRIANGLE_OBJECT_POSITIONS 86
#define NV_EXTN_OP_RT_MICRO_TRIANGLE_OBJECT_POSITIONS 87
#define NV_EXTN_OP_RT_MICRO_TRIANGLE_BARYCENTRICS 88
#define NV_EXTN_OP_RT_IS_MICRO_TRIANGLE_HIT 89
#define NV_EXTN_OP_RT_IS_BACK_FACING 90
#define NV_EXTN_OP_RT_MICRO_VERTEX_OBJECT_POSITION 91
#define NV_EXTN_OP_RT_MICRO_VERTEX_BARYCENTRICS 92
//----------------------------------------------------------------------------//
//-------------------- GET_SPECIAL subOpCode constants -----------------------//
//----------------------------------------------------------------------------//
#define NV_SPECIALOP_THREADLTMASK 4
#define NV_SPECIALOP_FOOTPRINT_SINGLELOD_PRED 5
#define NV_SPECIALOP_GLOBAL_TIMER_LO 9
#define NV_SPECIALOP_GLOBAL_TIMER_HI 10
//----------------------------------------------------------------------------//
//----------------------------- Texture Types -------------------------------//
//----------------------------------------------------------------------------//
#define NV_EXTN_TEXTURE_1D 2
#define NV_EXTN_TEXTURE_1D_ARRAY 3
#define NV_EXTN_TEXTURE_2D 4
#define NV_EXTN_TEXTURE_2D_ARRAY 5
#define NV_EXTN_TEXTURE_3D 6
#define NV_EXTN_TEXTURE_CUBE 7
#define NV_EXTN_TEXTURE_CUBE_ARRAY 8
//---------------------------------------------------------------------------//
//----------------FOOTPRINT Enums for NvFootprint* extns---------------------//
//---------------------------------------------------------------------------//
#define NV_EXTN_FOOTPRINT_MODE_FINE 0
#define NV_EXTN_FOOTPRINT_MODE_COARSE 1

24002
src/imports/nvapi/nvapi.h Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,529 @@
/*********************************************************************************************************\
|* *|
|* SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. *|
|* SPDX-License-Identifier: MIT *|
|* *|
|* 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 _NVAPI_INTERFACE_H
#define _NVAPI_INTERFACE_H
struct NVAPI_INTERFACE_TABLE { const char * func; unsigned int id; };
struct NVAPI_INTERFACE_TABLE nvapi_interface_table[] =
{
{ "NvAPI_Initialize", 0x0150e828 },
{ "NvAPI_Unload", 0xd22bdd7e },
{ "NvAPI_GetErrorMessage", 0x6c2d048c },
{ "NvAPI_GetInterfaceVersionString", 0x01053fa5 },
{ "NvAPI_GPU_GetEDID", 0x37d32e69 },
{ "NvAPI_SetView", 0x0957d7b6 },
{ "NvAPI_SetViewEx", 0x06b89e68 },
{ "NvAPI_GetDisplayDriverVersion", 0xf951a4d1 },
{ "NvAPI_SYS_GetDriverAndBranchVersion", 0x2926aaad },
{ "NvAPI_GPU_GetMemoryInfo", 0x07f9b368 },
{ "NvAPI_GPU_GetMemoryInfoEx", 0xc0599498 },
{ "NvAPI_OGL_ExpertModeSet", 0x3805ef7a },
{ "NvAPI_OGL_ExpertModeGet", 0x22ed9516 },
{ "NvAPI_OGL_ExpertModeDefaultsSet", 0xb47a657e },
{ "NvAPI_OGL_ExpertModeDefaultsGet", 0xae921f12 },
{ "NvAPI_EnumPhysicalGPUs", 0xe5ac921f },
{ "NvAPI_EnumTCCPhysicalGPUs", 0xd9930b07 },
{ "NvAPI_EnumLogicalGPUs", 0x48b3ea59 },
{ "NvAPI_GetPhysicalGPUsFromDisplay", 0x34ef9506 },
{ "NvAPI_GetPhysicalGPUFromUnAttachedDisplay", 0x5018ed61 },
{ "NvAPI_GetLogicalGPUFromDisplay", 0xee1370cf },
{ "NvAPI_GetLogicalGPUFromPhysicalGPU", 0xadd604d1 },
{ "NvAPI_GetPhysicalGPUsFromLogicalGPU", 0xaea3fa32 },
{ "NvAPI_GetPhysicalGPUFromGPUID", 0x5380ad1a },
{ "NvAPI_GetGPUIDfromPhysicalGPU", 0x6533ea3e },
{ "NvAPI_GPU_GetShaderSubPipeCount", 0x0be17923 },
{ "NvAPI_GPU_GetGpuCoreCount", 0xc7026a87 },
{ "NvAPI_GPU_GetAllOutputs", 0x7d554f8e },
{ "NvAPI_GPU_GetConnectedOutputs", 0x1730bfc9 },
{ "NvAPI_GPU_GetConnectedSLIOutputs", 0x0680de09 },
{ "NvAPI_GPU_GetConnectedDisplayIds", 0x0078dba2 },
{ "NvAPI_GPU_GetAllDisplayIds", 0x785210a2 },
{ "NvAPI_GPU_GetConnectedOutputsWithLidState", 0xcf8caf39 },
{ "NvAPI_GPU_GetConnectedSLIOutputsWithLidState", 0x96043cc7 },
{ "NvAPI_GPU_GetSystemType", 0xbaaabfcc },
{ "NvAPI_GPU_GetActiveOutputs", 0xe3e89b6f },
{ "NvAPI_GPU_SetEDID", 0xe83d6456 },
{ "NvAPI_GPU_GetOutputType", 0x40a505e4 },
{ "NvAPI_GPU_ValidateOutputCombination", 0x34c9c2d4 },
{ "NvAPI_GPU_GetFullName", 0xceee8e9f },
{ "NvAPI_GPU_GetPCIIdentifiers", 0x2ddfb66e },
{ "NvAPI_GPU_GetGPUType", 0xc33baeb1 },
{ "NvAPI_GPU_GetBusType", 0x1bb18724 },
{ "NvAPI_GPU_GetBusId", 0x1be0b8e5 },
{ "NvAPI_GPU_GetBusSlotId", 0x2a0a350f },
{ "NvAPI_GPU_GetIRQ", 0xe4715417 },
{ "NvAPI_GPU_GetVbiosRevision", 0xacc3da0a },
{ "NvAPI_GPU_GetVbiosOEMRevision", 0x2d43fb31 },
{ "NvAPI_GPU_GetVbiosVersionString", 0xa561fd7d },
{ "NvAPI_GPU_GetAGPAperture", 0x6e042794 },
{ "NvAPI_GPU_GetCurrentAGPRate", 0xc74925a0 },
{ "NvAPI_GPU_GetCurrentPCIEDownstreamWidth", 0xd048c3b1 },
{ "NvAPI_GPU_GetPhysicalFrameBufferSize", 0x46fbeb03 },
{ "NvAPI_GPU_GetVirtualFrameBufferSize", 0x5a04b644 },
{ "NvAPI_GPU_GetQuadroStatus", 0xe332fa47 },
{ "NvAPI_GPU_GetBoardInfo", 0x22d54523 },
{ "NvAPI_GPU_GetRamBusWidth", 0x7975c581 },
{ "NvAPI_GPU_GetArchInfo", 0xd8265d24 },
{ "NvAPI_I2CRead", 0x2fde12c5 },
{ "NvAPI_I2CWrite", 0xe812eb07 },
{ "NvAPI_GPU_WorkstationFeatureSetup", 0x6c1f3fe4 },
{ "NvAPI_GPU_WorkstationFeatureQuery", 0x004537df },
{ "NvAPI_GPU_GetHDCPSupportStatus", 0xf089eef5 },
{ "NvAPI_GPU_CudaEnumComputeCapableGpus", 0x5786cc6e },
{ "NvAPI_GPU_GetTachReading", 0x5f608315 },
{ "NvAPI_GPU_GetECCStatusInfo", 0xca1ddaf3 },
{ "NvAPI_GPU_GetECCErrorInfo", 0xc71f85a6 },
{ "NvAPI_GPU_ResetECCErrorInfo", 0xc02eec20 },
{ "NvAPI_GPU_GetECCConfigurationInfo", 0x77a796f3 },
{ "NvAPI_GPU_SetECCConfiguration", 0x1cf639d9 },
{ "NvAPI_GPU_QueryWorkstationFeatureSupport", 0x80b1abb9 },
{ "NvAPI_GPU_SetScanoutIntensity", 0xa57457a4 },
{ "NvAPI_GPU_GetScanoutIntensityState", 0xe81ce836 },
{ "NvAPI_GPU_SetScanoutWarping", 0xb34bab4f },
{ "NvAPI_GPU_GetScanoutWarpingState", 0x6f5435af },
{ "NvAPI_GPU_SetScanoutCompositionParameter", 0xf898247d },
{ "NvAPI_GPU_GetScanoutCompositionParameter", 0x58fe51e6 },
{ "NvAPI_GPU_GetScanoutConfiguration", 0x6a9f5b63 },
{ "NvAPI_GPU_GetScanoutConfigurationEx", 0xe2e1e6f0 },
{ "NvAPI_GPU_GetAdapterIdFromPhysicalGpu", 0x0ff07fde },
{ "NvAPI_GPU_GetVirtualizationInfo", 0x44e022a9 },
{ "NvAPI_GPU_GetLogicalGpuInfo", 0x842b066e },
{ "NvAPI_GPU_GetLicensableFeatures", 0x3fc596aa },
{ "NvAPI_GPU_NVLINK_GetCaps", 0xbef1119d },
{ "NvAPI_GPU_NVLINK_GetStatus", 0xc72a38e3 },
{ "NvAPI_GPU_GetGPUInfo", 0xafd1b02c },
{ "NvAPI_GPU_GetVRReadyData", 0x81d629c5 },
{ "NvAPI_GPU_GetGspFeatures", 0x581c4391 },
{ "NvAPI_GPU_GetPerfDecreaseInfo", 0x7f7f4600 },
{ "NvAPI_GPU_GetPstatesInfoEx", 0x843c0256 },
{ "NvAPI_GPU_GetPstates20", 0x6ff81213 },
{ "NvAPI_GPU_GetCurrentPstate", 0x927da4f6 },
{ "NvAPI_GPU_GetDynamicPstatesInfoEx", 0x60ded2ed },
{ "NvAPI_GPU_GetThermalSettings", 0xe3640a56 },
{ "NvAPI_GPU_GetAllClockFrequencies", 0xdcb616c3 },
{ "NvAPI_GPU_QueryIlluminationSupport", 0xa629da31 },
{ "NvAPI_GPU_GetIllumination", 0x9a1b9365 },
{ "NvAPI_GPU_SetIllumination", 0x0254a187 },
{ "NvAPI_GPU_ClientIllumDevicesGetInfo", 0xd4100e58 },
{ "NvAPI_GPU_ClientIllumDevicesGetControl", 0x73c01d58 },
{ "NvAPI_GPU_ClientIllumDevicesSetControl", 0x57024c62 },
{ "NvAPI_GPU_ClientIllumZonesGetInfo", 0x4b81241b },
{ "NvAPI_GPU_ClientIllumZonesGetControl", 0x3dbf5764 },
{ "NvAPI_GPU_ClientIllumZonesSetControl", 0x197d065e },
{ "NvAPI_Event_RegisterCallback", 0xe6dbea69 },
{ "NvAPI_Event_UnregisterCallback", 0xde1f9b45 },
{ "NvAPI_EnumNvidiaDisplayHandle", 0x9abdd40d },
{ "NvAPI_EnumNvidiaUnAttachedDisplayHandle", 0x20de9260 },
{ "NvAPI_CreateDisplayFromUnAttachedDisplay", 0x63f9799e },
{ "NvAPI_GetAssociatedNvidiaDisplayHandle", 0x35c29134 },
{ "NvAPI_DISP_GetAssociatedUnAttachedNvidiaDisplayHandle", 0xa70503b2 },
{ "NvAPI_GetAssociatedNvidiaDisplayName", 0x22a78b05 },
{ "NvAPI_GetUnAttachedAssociatedDisplayName", 0x4888d790 },
{ "NvAPI_EnableHWCursor", 0x2863148d },
{ "NvAPI_DisableHWCursor", 0xab163097 },
{ "NvAPI_GetVBlankCounter", 0x67b5db55 },
{ "NvAPI_SetRefreshRateOverride", 0x3092ac32 },
{ "NvAPI_GetAssociatedDisplayOutputId", 0xd995937e },
{ "NvAPI_GetDisplayPortInfo", 0xc64ff367 },
{ "NvAPI_SetDisplayPort", 0xfa13e65a },
{ "NvAPI_GetHDMISupportInfo", 0x6ae16ec3 },
{ "NvAPI_Disp_InfoFrameControl", 0x6067af3f },
{ "NvAPI_Disp_ColorControl", 0x92f9d80d },
{ "NvAPI_Disp_GetHdrCapabilities", 0x84f2a8df },
{ "NvAPI_Disp_HdrColorControl", 0x351da224 },
{ "NvAPI_Disp_SetSourceColorSpace", 0x473b6caf },
{ "NvAPI_Disp_GetSourceColorSpace", 0xceedc85b },
{ "NvAPI_Disp_SetSourceHdrMetadata", 0x905eb63b },
{ "NvAPI_Disp_GetSourceHdrMetadata", 0x0d3f52da },
{ "NvAPI_Disp_SetOutputMode", 0x98e7661a },
{ "NvAPI_Disp_GetOutputMode", 0x81fed88d },
{ "NvAPI_Disp_SetHdrToneMapping", 0xdd6da362 },
{ "NvAPI_Disp_GetHdrToneMapping", 0xfbd36e71 },
{ "NvAPI_DISP_GetTiming", 0x175167e9 },
{ "NvAPI_DISP_GetMonitorCapabilities", 0x3b05c7e1 },
{ "NvAPI_DISP_GetMonitorColorCapabilities", 0x6ae4cfb5 },
{ "NvAPI_DISP_EnumCustomDisplay", 0xa2072d59 },
{ "NvAPI_DISP_TryCustomDisplay", 0x1f7db630 },
{ "NvAPI_DISP_DeleteCustomDisplay", 0x552e5b9b },
{ "NvAPI_DISP_SaveCustomDisplay", 0x49882876 },
{ "NvAPI_DISP_RevertCustomDisplayTrial", 0xcbbd40f0 },
{ "NvAPI_GetView", 0xd6b99d89 },
{ "NvAPI_GetViewEx", 0xdbbc0af4 },
{ "NvAPI_GetSupportedViews", 0x66fb7fc0 },
{ "NvAPI_DISP_GetDisplayIdByDisplayName", 0xae457190 },
{ "NvAPI_DISP_GetGDIPrimaryDisplayId", 0x1e9d8a31 },
{ "NvAPI_DISP_GetDisplayConfig", 0x11abccf8 },
{ "NvAPI_DISP_SetDisplayConfig", 0x5d8cf8de },
{ "NvAPI_DISP_GetEdidData", 0x436ced76 },
{ "NvAPI_DISP_GetAdaptiveSyncData", 0xb73d1ee9 },
{ "NvAPI_DISP_SetAdaptiveSyncData", 0x3eebba1d },
{ "NvAPI_DISP_GetVirtualRefreshRateData", 0x8c00429a },
{ "NvAPI_DISP_SetVirtualRefreshRateData", 0x5abbe6a3 },
{ "NvAPI_DISP_SetPreferredStereoDisplay", 0xc9d0e25f },
{ "NvAPI_DISP_GetPreferredStereoDisplay", 0x1f6b4666 },
{ "NvAPI_DISP_GetNvManagedDedicatedDisplays", 0xdbdf0cb2 },
{ "NvAPI_DISP_AcquireDedicatedDisplay", 0x47c917ba },
{ "NvAPI_DISP_ReleaseDedicatedDisplay", 0x1247825f },
{ "NvAPI_DISP_GetNvManagedDedicatedDisplayMetadata", 0xd645d80c },
{ "NvAPI_DISP_SetNvManagedDedicatedDisplayMetadata", 0x3d8b129a },
{ "NvAPI_Disp_GetDisplayIdInfo", 0xbae8aa5e },
{ "NvAPI_Disp_GetDisplayIdsFromTarget", 0xe7e5f89e },
{ "NvAPI_Disp_GetVRRInfo", 0xdf8fda57 },
{ "NvAPI_Mosaic_GetSupportedTopoInfo", 0xfdb63c81 },
{ "NvAPI_Mosaic_GetTopoGroup", 0xcb89381d },
{ "NvAPI_Mosaic_GetOverlapLimits", 0x989685f0 },
{ "NvAPI_Mosaic_SetCurrentTopo", 0x9b542831 },
{ "NvAPI_Mosaic_GetCurrentTopo", 0xec32944e },
{ "NvAPI_Mosaic_EnableCurrentTopo", 0x5f1aa66c },
{ "NvAPI_Mosaic_GetDisplayViewportsByResolution", 0xdc6dc8d3 },
{ "NvAPI_Mosaic_SetDisplayGrids", 0x4d959a89 },
{ "NvAPI_Mosaic_ValidateDisplayGrids", 0xcf43903d },
{ "NvAPI_Mosaic_EnumDisplayModes", 0x78db97d7 },
{ "NvAPI_Mosaic_EnumDisplayGrids", 0xdf2887af },
{ "NvAPI_GetSupportedMosaicTopologies", 0x410b5c25 },
{ "NvAPI_GetCurrentMosaicTopology", 0xf60852bd },
{ "NvAPI_SetCurrentMosaicTopology", 0xd54b8989 },
{ "NvAPI_EnableCurrentMosaicTopology", 0x74073cc9 },
{ "NvAPI_GSync_EnumSyncDevices", 0xd9639601 },
{ "NvAPI_GSync_QueryCapabilities", 0x44a3f1d1 },
{ "NvAPI_GSync_GetTopology", 0x4562bc38 },
{ "NvAPI_GSync_SetSyncStateSettings", 0x60acdfdd },
{ "NvAPI_GSync_GetControlParameters", 0x16de1c6a },
{ "NvAPI_GSync_SetControlParameters", 0x8bbff88b },
{ "NvAPI_GSync_AdjustSyncDelay", 0x2d11ff51 },
{ "NvAPI_GSync_GetSyncStatus", 0xf1f5b434 },
{ "NvAPI_GSync_GetStatusParameters", 0x70d404ec },
{ "NvAPI_D3D_GetCurrentSLIState", 0x4b708b54 },
{ "NvAPI_D3D9_RegisterResource", 0xa064bdfc },
{ "NvAPI_D3D9_UnregisterResource", 0xbb2b17aa },
{ "NvAPI_D3D9_AliasSurfaceAsTexture", 0xe5ceae41 },
{ "NvAPI_D3D9_StretchRectEx", 0x22de03aa },
{ "NvAPI_D3D9_ClearRT", 0x332d3942 },
{ "NvAPI_D3D_GetObjectHandleForResource", 0xfceac864 },
{ "NvAPI_D3D_SetResourceHint", 0x6c0ed98c },
{ "NvAPI_D3D_BeginResourceRendering", 0x91123d6a },
{ "NvAPI_D3D_EndResourceRendering", 0x37e7191c },
{ "NvAPI_D3D9_GetSurfaceHandle", 0x0f2dd3f2 },
{ "NvAPI_D3D9_VideoSetStereoInfo", 0xb852f4db },
{ "NvAPI_D3D10_SetDepthBoundsTest", 0x4eadf5d2 },
{ "NvAPI_D3D11_CreateDevice", 0x6a16d3a0 },
{ "NvAPI_D3D11_CreateDeviceAndSwapChain", 0xbb939ee5 },
{ "NvAPI_D3D11_SetDepthBoundsTest", 0x7aaf7a04 },
{ "NvAPI_D3D11_IsNvShaderExtnOpCodeSupported", 0x5f68da40 },
{ "NvAPI_D3D11_SetNvShaderExtnSlot", 0x8e90bb9f },
{ "NvAPI_D3D12_SetNvShaderExtnSlotSpace", 0xac2dfeb5 },
{ "NvAPI_D3D12_SetNvShaderExtnSlotSpaceLocalThread", 0x43d867c0 },
{ "NvAPI_D3D11_SetNvShaderExtnSlotLocalThread", 0x0e6482a0 },
{ "NvAPI_D3D11_BeginUAVOverlapEx", 0xba08208a },
{ "NvAPI_D3D11_BeginUAVOverlap", 0x65b93ca8 },
{ "NvAPI_D3D11_EndUAVOverlap", 0x2216a357 },
{ "NvAPI_D3D11_GetResourceHandle", 0x09d52986 },
{ "NvAPI_D3D_SetFPSIndicatorState", 0xa776e8db },
{ "NvAPI_D3D9_Present", 0x05650beb },
{ "NvAPI_D3D9_QueryFrameCount", 0x9083e53a },
{ "NvAPI_D3D9_ResetFrameCount", 0xfa6a0675 },
{ "NvAPI_D3D9_QueryMaxSwapGroup", 0x5995410d },
{ "NvAPI_D3D9_QuerySwapGroup", 0xeba4d232 },
{ "NvAPI_D3D9_JoinSwapGroup", 0x7d44bb54 },
{ "NvAPI_D3D9_BindSwapBarrier", 0x9c39c246 },
{ "NvAPI_D3D_SetVerticalSyncMode", 0x5526cfd1 },
{ "NvAPI_D3D1x_Present", 0x03b845a1 },
{ "NvAPI_D3D1x_QueryFrameCount", 0x9152e055 },
{ "NvAPI_D3D1x_ResetFrameCount", 0xfbbb031a },
{ "NvAPI_D3D1x_QueryMaxSwapGroup", 0x9bb9d68f },
{ "NvAPI_D3D1x_QuerySwapGroup", 0x407f67aa },
{ "NvAPI_D3D1x_JoinSwapGroup", 0x14610cd7 },
{ "NvAPI_D3D1x_BindSwapBarrier", 0x9de8c729 },
{ "NvAPI_D3D12_QueryPresentBarrierSupport", 0xa15faef7 },
{ "NvAPI_D3D12_CreatePresentBarrierClient", 0x4d815de9 },
{ "NvAPI_D3D12_RegisterPresentBarrierResources", 0xd53c9ef0 },
{ "NvAPI_DestroyPresentBarrierClient", 0x3c5c351b },
{ "NvAPI_JoinPresentBarrier", 0x17f6bf82 },
{ "NvAPI_LeavePresentBarrier", 0xc3ec5a7f },
{ "NvAPI_QueryPresentBarrierFrameStatistics", 0x61b844a1 },
{ "NvAPI_D3D12_CreateDDisplayPresentBarrierClient", 0xb5a21987 },
{ "NvAPI_D3D11_CreateRasterizerState", 0xdb8d28af },
{ "NvAPI_D3D_ConfigureAnsel", 0x341c6c7f },
{ "NvAPI_D3D11_CreateTiledTexture2DArray", 0x7886981a },
{ "NvAPI_D3D11_CheckFeatureSupport", 0x106a487e },
{ "NvAPI_D3D11_CreateImplicitMSAATexture2D", 0xb8f79632 },
{ "NvAPI_D3D12_CreateCommittedImplicitMSAATexture2D", 0x24c6a07b },
{ "NvAPI_D3D11_ResolveSubresourceRegion", 0xe6bfedd6 },
{ "NvAPI_D3D12_ResolveSubresourceRegion", 0xc24a15bf },
{ "NvAPI_D3D11_TiledTexture2DArrayGetDesc", 0xf1a2b9d5 },
{ "NvAPI_D3D11_UpdateTileMappings", 0x9a06ea07 },
{ "NvAPI_D3D11_CopyTileMappings", 0xc09ee6bc },
{ "NvAPI_D3D11_TiledResourceBarrier", 0xd6839099 },
{ "NvAPI_D3D11_AliasMSAATexture2DAsNonMSAA", 0xf1c54fc9 },
{ "NvAPI_D3D11_CreateGeometryShaderEx_2", 0x99ed5c1c },
{ "NvAPI_D3D11_CreateVertexShaderEx", 0x0beaa0b2 },
{ "NvAPI_D3D11_CreateHullShaderEx", 0xb53cab00 },
{ "NvAPI_D3D11_CreateDomainShaderEx", 0xa0d7180d },
{ "NvAPI_D3D11_CreatePixelShaderEx_2", 0x4162822b },
{ "NvAPI_D3D11_CreateFastGeometryShaderExplicit", 0x71ab7c9c },
{ "NvAPI_D3D11_CreateFastGeometryShader", 0x525d43be },
{ "NvAPI_D3D11_DecompressView", 0x3a94e822 },
{ "NvAPI_D3D12_CreateGraphicsPipelineState", 0x2fc28856 },
{ "NvAPI_D3D12_CreateComputePipelineState", 0x2762deac },
{ "NvAPI_D3D12_SetDepthBoundsTestValues", 0xb9333fe9 },
{ "NvAPI_D3D12_CreateReservedResource", 0x2c85f101 },
{ "NvAPI_D3D12_CreateHeap", 0x5cb397cf },
{ "NvAPI_D3D12_CreateHeap2", 0x924be9d6 },
{ "NvAPI_D3D12_QueryCpuVisibleVidmem", 0x26322bc3 },
{ "NvAPI_D3D12_ReservedResourceGetDesc", 0x9aa2aabb },
{ "NvAPI_D3D12_UpdateTileMappings", 0xc6017a7d },
{ "NvAPI_D3D12_CopyTileMappings", 0x47f78194 },
{ "NvAPI_D3D12_ResourceAliasingBarrier", 0xb942bab7 },
{ "NvAPI_D3D12_CaptureUAVInfo", 0x6e5ea9db },
{ "NvAPI_D3D11_GetResourceGPUVirtualAddressEx", 0xaf6d14da },
{ "NvAPI_D3D11_EnumerateMetaCommands", 0xc7453ba8 },
{ "NvAPI_D3D11_CreateMetaCommand", 0xf505fba0 },
{ "NvAPI_D3D11_InitializeMetaCommand", 0xaec629e9 },
{ "NvAPI_D3D11_ExecuteMetaCommand", 0x82236c47 },
{ "NvAPI_D3D12_EnumerateMetaCommands", 0xcd9141d8 },
{ "NvAPI_D3D12_CreateMetaCommand", 0xeb29634b },
{ "NvAPI_D3D12_InitializeMetaCommand", 0xa4125399 },
{ "NvAPI_D3D12_ExecuteMetaCommand", 0xde24fc3d },
{ "NvAPI_D3D12_CreateCommittedResource", 0x027e98ae },
{ "NvAPI_D3D12_GetCopyableFootprints", 0xf6305eb5 },
{ "NvAPI_D3D12_CopyTextureRegion", 0x82b91b25 },
{ "NvAPI_D3D12_IsNvShaderExtnOpCodeSupported", 0x3dfacec8 },
{ "NvAPI_D3D12_GetOptimalThreadCountForMesh", 0xb43995cb },
{ "NvAPI_D3D_IsGSyncCapable", 0x9c1eed78 },
{ "NvAPI_D3D_IsGSyncActive", 0xe942b0ff },
{ "NvAPI_D3D1x_DisableShaderDiskCache", 0xd0cbca7d },
{ "NvAPI_D3D11_MultiGPU_GetCaps", 0xd2d25687 },
{ "NvAPI_D3D11_MultiGPU_Init", 0x017be49e },
{ "NvAPI_D3D11_CreateMultiGPUDevice", 0xbdb20007 },
{ "NvAPI_D3D_QuerySinglePassStereoSupport", 0x6f5f0a6d },
{ "NvAPI_D3D_SetSinglePassStereoMode", 0xa39e6e6e },
{ "NvAPI_D3D12_QuerySinglePassStereoSupport", 0x3b03791b },
{ "NvAPI_D3D12_SetSinglePassStereoMode", 0x83556d87 },
{ "NvAPI_D3D_QueryMultiViewSupport", 0xb6e0a41c },
{ "NvAPI_D3D_SetMultiViewMode", 0x8285c8da },
{ "NvAPI_D3D_QueryModifiedWSupport", 0xcbf9f4f5 },
{ "NvAPI_D3D_SetModifiedWMode", 0x06ea4bf4 },
{ "NvAPI_D3D12_QueryModifiedWSupport", 0x51235248 },
{ "NvAPI_D3D12_SetModifiedWMode", 0xe1fdaba7 },
{ "NvAPI_D3D_CreateLateLatchObject", 0x2db27d09 },
{ "NvAPI_D3D_QueryLateLatchSupport", 0x8ceca0ec },
{ "NvAPI_D3D_RegisterDevice", 0x8c02c4d0 },
{ "NvAPI_D3D11_MultiDrawInstancedIndirect", 0xd4e26bbf },
{ "NvAPI_D3D11_MultiDrawIndexedInstancedIndirect", 0x59e890f9 },
{ "NvAPI_D3D_ImplicitSLIControl", 0x2aede111 },
{ "NvAPI_D3D12_GetNeedsAppFPBlendClamping", 0x6ef4d2d1 },
{ "NvAPI_D3D12_UseDriverHeapPriorities", 0xf0d978a8 },
{ "NvAPI_D3D12_Mosaic_GetCompanionAllocations", 0xa46022c7 },
{ "NvAPI_D3D12_Mosaic_GetViewportAndGpuPartitions", 0xb092b818 },
{ "NvAPI_D3D1x_GetGraphicsCapabilities", 0x52b1499a },
{ "NvAPI_D3D12_GetGraphicsCapabilities", 0x01e87354 },
{ "NvAPI_D3D11_RSSetExclusiveScissorRects", 0xae4d73ef },
{ "NvAPI_D3D11_RSSetViewportsPixelShadingRates", 0x34f7938f },
{ "NvAPI_D3D11_CreateShadingRateResourceView", 0x99ca2dff },
{ "NvAPI_D3D11_RSSetShadingRateResourceView", 0x1b0c2f83 },
{ "NvAPI_D3D11_RSGetPixelShadingRateSampleOrder", 0x092442a1 },
{ "NvAPI_D3D11_RSSetPixelShadingRateSampleOrder", 0xa942373a },
{ "NvAPI_D3D_InitializeVRSHelper", 0x4780d70b },
{ "NvAPI_D3D_InitializeNvGazeHandler", 0x5b3b7479 },
{ "NvAPI_D3D_InitializeSMPAssist", 0x42763d0c },
{ "NvAPI_D3D_QuerySMPAssistSupport", 0xc57921de },
{ "NvAPI_D3D_GetSleepStatus", 0xaef96ca1 },
{ "NvAPI_D3D_SetSleepMode", 0xac1ca9e0 },
{ "NvAPI_D3D_Sleep", 0x852cd1d2 },
{ "NvAPI_D3D_SetReflexSync", 0xb9f6faff },
{ "NvAPI_D3D_GetLatency", 0x1a587f9c },
{ "NvAPI_D3D_SetLatencyMarker", 0xd9984c05 },
{ "NvAPI_D3D12_SetAsyncFrameMarker", 0x13c98f73 },
{ "NvAPI_D3D11_SetAsyncFrameMarker", 0x59c2c510 },
{ "NvAPI_D3D12_NotifyOutOfBandCommandQueue", 0x03d6e8cb },
{ "NvAPI_D3D12_SetCreateCommandQueueLowLatencyHint", 0x548c224f },
{ "NvAPI_D3D12_CreateCubinComputeShaderExV2", 0x299f5fdc },
{ "NvAPI_D3D12_CreateCubinComputeShader", 0x2a2c79e8 },
{ "NvAPI_D3D12_CreateCubinComputeShaderEx", 0x3151211b },
{ "NvAPI_D3D12_CreateCubinComputeShaderWithName", 0x1dc7261f },
{ "NvAPI_D3D12_LaunchCubinShader", 0x5c52bb86 },
{ "NvAPI_D3D12_DestroyCubinComputeShader", 0x7fb785ba },
{ "NvAPI_D3D12_GetCudaMergedTextureSamplerObject", 0x329fe6e0 },
{ "NvAPI_D3D12_GetCudaIndependentDescriptorObject", 0x0ddac234 },
{ "NvAPI_D3D12_GetCudaTextureObject", 0x80403fc9 },
{ "NvAPI_D3D12_GetCudaSurfaceObject", 0x48f5b2ee },
{ "NvAPI_D3D12_IsFatbinPTXSupported", 0x70c07832 },
{ "NvAPI_D3D12_CreateCuModule", 0xad1a677d },
{ "NvAPI_D3D12_EnumFunctionsInModule", 0x7ab88d88 },
{ "NvAPI_D3D12_CreateCuFunction", 0xe2436e22 },
{ "NvAPI_D3D12_LaunchCuKernelChain", 0x24973538 },
{ "NvAPI_D3D12_LaunchCuKernelChainEx", 0x846a9bf0 },
{ "NvAPI_D3D12_DestroyCuModule", 0x41c65285 },
{ "NvAPI_D3D12_DestroyCuFunction", 0xdf295ea6 },
{ "NvAPI_D3D11_CreateCubinComputeShader", 0x0ed98181 },
{ "NvAPI_D3D11_CreateCubinComputeShaderEx", 0x32c2a0f6 },
{ "NvAPI_D3D11_CreateCubinComputeShaderWithName", 0xb672be19 },
{ "NvAPI_D3D11_LaunchCubinShader", 0x427e236d },
{ "NvAPI_D3D11_DestroyCubinComputeShader", 0x01682c86 },
{ "NvAPI_D3D11_IsFatbinPTXSupported", 0x6086bd93 },
{ "NvAPI_D3D11_CreateUnorderedAccessView", 0x74a497a1 },
{ "NvAPI_D3D11_CreateShaderResourceView", 0x65cb431e },
{ "NvAPI_D3D11_CreateSamplerState", 0x89eca416 },
{ "NvAPI_D3D11_GetCudaTextureObject", 0x9006fa68 },
{ "NvAPI_D3D11_GetResourceGPUVirtualAddress", 0x1819b423 },
{ "NvAPI_D3D12_GetRaytracingCaps", 0x85a6c2a0 },
{ "NvAPI_D3D12_EnableRaytracingValidation", 0x1de5991b },
{ "NvAPI_D3D12_RegisterRaytracingValidationMessageCallback", 0x8554eb38 },
{ "NvAPI_D3D12_UnregisterRaytracingValidationMessageCallback", 0x26975da6 },
{ "NvAPI_D3D12_FlushRaytracingValidationMessages", 0xb8fb1fcb },
{ "NvAPI_D3D12_GetRaytracingDisplacementMicromapArrayPrebuildInfo", 0xfa99b6de },
{ "NvAPI_D3D12_GetRaytracingOpacityMicromapArrayPrebuildInfo", 0x4726d180 },
{ "NvAPI_D3D12_SetCreatePipelineStateOptions", 0x5c607a27 },
{ "NvAPI_D3D12_CheckDriverMatchingIdentifierEx", 0xafb237d4 },
{ "NvAPI_D3D12_GetRaytracingAccelerationStructurePrebuildInfoEx", 0x8d025b77 },
{ "NvAPI_D3D12_BuildRaytracingOpacityMicromapArray", 0x814f8d11 },
{ "NvAPI_D3D12_RelocateRaytracingOpacityMicromapArray", 0x0425c538 },
{ "NvAPI_D3D12_BuildRaytracingDisplacementMicromapArray", 0x066f569d },
{ "NvAPI_D3D12_RelocateRaytracingDisplacementMicromapArray", 0x1c142308 },
{ "NvAPI_D3D12_EmitRaytracingDisplacementMicromapArrayPostbuildInfo", 0x68b9a790 },
{ "NvAPI_D3D12_EmitRaytracingOpacityMicromapArrayPostbuildInfo", 0x1d9a39b6 },
{ "NvAPI_D3D12_BuildRaytracingAccelerationStructureEx", 0xe24ead45 },
{ "NvAPI_D3D12_QueryWorkstationFeatureProperties", 0xa92ea23a },
{ "NvAPI_D3D12_CreateCommittedRDMABuffer", 0xe78dcb44 },
{ "NvAPI_DirectD3D12GraphicsCommandList_Create", 0x74a4e712 },
{ "NvAPI_DirectD3D12GraphicsCommandList_Release", 0x99da3dde },
{ "NvAPI_DirectD3D12GraphicsCommandList_Reset", 0x999c26d8 },
{ "NvAPI_VIO_GetCapabilities", 0x1dc91303 },
{ "NvAPI_VIO_Open", 0x44ee4841 },
{ "NvAPI_VIO_Close", 0xd01bd237 },
{ "NvAPI_VIO_Status", 0x0e6ce4f1 },
{ "NvAPI_VIO_SyncFormatDetect", 0x118d48a3 },
{ "NvAPI_VIO_GetConfig", 0xd34a789b },
{ "NvAPI_VIO_SetConfig", 0x0e4eec07 },
{ "NvAPI_VIO_SetCSC", 0xa1ec8d74 },
{ "NvAPI_VIO_GetCSC", 0x7b0d72a3 },
{ "NvAPI_VIO_SetGamma", 0x964bf452 },
{ "NvAPI_VIO_GetGamma", 0x51d53d06 },
{ "NvAPI_VIO_SetSyncDelay", 0x2697a8d1 },
{ "NvAPI_VIO_GetSyncDelay", 0x462214a9 },
{ "NvAPI_VIO_GetPCIInfo", 0xb981d935 },
{ "NvAPI_VIO_IsRunning", 0x96bd040e },
{ "NvAPI_VIO_Start", 0xcde8e1a3 },
{ "NvAPI_VIO_Stop", 0x6ba2a5d6 },
{ "NvAPI_VIO_IsFrameLockModeCompatible", 0x7bf0a94d },
{ "NvAPI_VIO_EnumDevices", 0xfd7c5557 },
{ "NvAPI_VIO_QueryTopology", 0x869534e2 },
{ "NvAPI_VIO_EnumSignalFormats", 0xead72fe4 },
{ "NvAPI_VIO_EnumDataFormats", 0x221fa8e8 },
{ "NvAPI_Stereo_CreateConfigurationProfileRegistryKey", 0xbe7692ec },
{ "NvAPI_Stereo_DeleteConfigurationProfileRegistryKey", 0xf117b834 },
{ "NvAPI_Stereo_SetConfigurationProfileValue", 0x24409f48 },
{ "NvAPI_Stereo_DeleteConfigurationProfileValue", 0x49bceecf },
{ "NvAPI_Stereo_Enable", 0x239c4545 },
{ "NvAPI_Stereo_Disable", 0x2ec50c2b },
{ "NvAPI_Stereo_IsEnabled", 0x348ff8e1 },
{ "NvAPI_Stereo_GetStereoSupport", 0x296c434d },
{ "NvAPI_Stereo_CreateHandleFromIUnknown", 0xac7e37f4 },
{ "NvAPI_Stereo_DestroyHandle", 0x3a153134 },
{ "NvAPI_Stereo_Activate", 0xf6a1ad68 },
{ "NvAPI_Stereo_Deactivate", 0x2d68de96 },
{ "NvAPI_Stereo_IsActivated", 0x1fb0bc30 },
{ "NvAPI_Stereo_GetSeparation", 0x451f2134 },
{ "NvAPI_Stereo_SetSeparation", 0x5c069fa3 },
{ "NvAPI_Stereo_DecreaseSeparation", 0xda044458 },
{ "NvAPI_Stereo_IncreaseSeparation", 0xc9a8ecec },
{ "NvAPI_Stereo_GetConvergence", 0x4ab00934 },
{ "NvAPI_Stereo_SetConvergence", 0x3dd6b54b },
{ "NvAPI_Stereo_DecreaseConvergence", 0x4c87e317 },
{ "NvAPI_Stereo_IncreaseConvergence", 0xa17daabe },
{ "NvAPI_Stereo_GetFrustumAdjustMode", 0xe6839b43 },
{ "NvAPI_Stereo_SetFrustumAdjustMode", 0x7be27fa2 },
{ "NvAPI_Stereo_CaptureJpegImage", 0x932cb140 },
{ "NvAPI_Stereo_InitActivation", 0xc7177702 },
{ "NvAPI_Stereo_Trigger_Activation", 0x0d6c6cd2 },
{ "NvAPI_Stereo_CapturePngImage", 0x8b7e99b5 },
{ "NvAPI_Stereo_ReverseStereoBlitControl", 0x3cd58f89 },
{ "NvAPI_Stereo_SetNotificationMessage", 0x6b9b409e },
{ "NvAPI_Stereo_SetActiveEye", 0x96eea9f8 },
{ "NvAPI_Stereo_SetDriverMode", 0x5e8f0bec },
{ "NvAPI_Stereo_GetEyeSeparation", 0xce653127 },
{ "NvAPI_Stereo_IsWindowedModeSupported", 0x40c8ed5e },
{ "NvAPI_Stereo_SetSurfaceCreationMode", 0xf5dcfcba },
{ "NvAPI_Stereo_GetSurfaceCreationMode", 0x36f1c736 },
{ "NvAPI_Stereo_Debug_WasLastDrawStereoized", 0xed4416c5 },
{ "NvAPI_Stereo_SetDefaultProfile", 0x44f0ecd1 },
{ "NvAPI_Stereo_GetDefaultProfile", 0x624e21c2 },
{ "NvAPI_D3D1x_CreateSwapChain", 0x1bc21b66 },
{ "NvAPI_D3D9_CreateSwapChain", 0x1a131e09 },
{ "NvAPI_Vulkan_InitLowLatencyDevice", 0x5c1696b6 },
{ "NvAPI_Vulkan_DestroyLowLatencyDevice", 0x11a5932b },
{ "NvAPI_Vulkan_GetSleepStatus", 0xadf966af },
{ "NvAPI_Vulkan_SetSleepMode", 0x2acfd162 },
{ "NvAPI_Vulkan_Sleep", 0x36732b1e },
{ "NvAPI_Vulkan_GetLatency", 0x3233d44a },
{ "NvAPI_Vulkan_SetLatencyMarker", 0xa17d13d6 },
{ "NvAPI_Vulkan_NotifyOutOfBandVkQueue", 0x5d6d3840 },
{ "NvAPI_DRS_CreateSession", 0x0694d52e },
{ "NvAPI_DRS_DestroySession", 0xdad9cff8 },
{ "NvAPI_DRS_LoadSettings", 0x375dbd6b },
{ "NvAPI_DRS_SaveSettings", 0xfcbc7e14 },
{ "NvAPI_DRS_LoadSettingsFromFile", 0xd3ede889 },
{ "NvAPI_DRS_SaveSettingsToFile", 0x2be25df8 },
{ "NvAPI_DRS_CreateProfile", 0xcc176068 },
{ "NvAPI_DRS_DeleteProfile", 0x17093206 },
{ "NvAPI_DRS_SetCurrentGlobalProfile", 0x1c89c5df },
{ "NvAPI_DRS_GetCurrentGlobalProfile", 0x617bff9f },
{ "NvAPI_DRS_GetProfileInfo", 0x61cd6fd6 },
{ "NvAPI_DRS_SetProfileInfo", 0x16abd3a9 },
{ "NvAPI_DRS_FindProfileByName", 0x7e4a9a0b },
{ "NvAPI_DRS_EnumProfiles", 0xbc371ee0 },
{ "NvAPI_DRS_GetNumProfiles", 0x1dae4fbc },
{ "NvAPI_DRS_CreateApplication", 0x4347a9de },
{ "NvAPI_DRS_DeleteApplicationEx", 0xc5ea85a1 },
{ "NvAPI_DRS_DeleteApplication", 0x2c694bc6 },
{ "NvAPI_DRS_GetApplicationInfo", 0xed1f8c69 },
{ "NvAPI_DRS_EnumApplications", 0x7fa2173a },
{ "NvAPI_DRS_FindApplicationByName", 0xeee566b2 },
{ "NvAPI_DRS_SetSetting", 0x577dd202 },
{ "NvAPI_DRS_GetSetting", 0x73bf8338 },
{ "NvAPI_DRS_EnumSettings", 0xae3039da },
{ "NvAPI_DRS_EnumAvailableSettingIds", 0xf020614a },
{ "NvAPI_DRS_EnumAvailableSettingValues", 0x2ec39f90 },
{ "NvAPI_DRS_GetSettingIdFromName", 0xcb7309cd },
{ "NvAPI_DRS_GetSettingNameFromId", 0xd61cbe6e },
{ "NvAPI_DRS_DeleteProfileSetting", 0xe4a26362 },
{ "NvAPI_DRS_RestoreAllDefaults", 0x5927b094 },
{ "NvAPI_DRS_RestoreProfileDefault", 0xfa5f6134 },
{ "NvAPI_DRS_RestoreProfileDefaultSetting", 0x53f0381e },
{ "NvAPI_DRS_GetBaseProfile", 0xda8466a0 },
{ "NvAPI_SYS_GetChipSetInfo", 0x53dabbca },
{ "NvAPI_SYS_GetLidAndDockInfo", 0xcda14d8a },
{ "NvAPI_SYS_GetDisplayIdFromGpuAndOutputId", 0x08f2bab4 },
{ "NvAPI_SYS_GetGpuAndOutputIdFromDisplayId", 0x112ba1a5 },
{ "NvAPI_SYS_GetPhysicalGpuFromDisplayId", 0x9ea74659 },
{ "NvAPI_SYS_GetDisplayDriverInfo", 0x721faceb },
{ "NvAPI_SYS_GetPhysicalGPUs", 0xd3b24d2d },
{ "NvAPI_SYS_GetLogicalGPUs", 0xccfffc10 },
{ "NvAPI_GPU_ClientRegisterForUtilizationSampleUpdates", 0xadeeaf67 },
};
#endif // _NVAPI_INTERFACE_H

View File

@@ -0,0 +1,659 @@
/*********************************************************************************************************\
|* *|
|* SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. *|
|* SPDX-License-Identifier: MIT *|
|* *|
|* 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"imports/nvapi/nvapi_lite_salstart.h"
#pragma pack(push,8)
#ifdef __cplusplus
extern "C" {
#endif
#if (defined(WIN32) || defined(_WIN32)) && defined(_MSC_VER) && (_MSC_VER > 1399) && !defined(NVAPI_INTERNAL) && !defined(NVAPI_DEPRECATED_OLD)
#ifndef __nvapi_deprecated_function
#define __nvapi_deprecated_function(message) __declspec(deprecated(message))
#endif
#ifndef __nvapi_deprecated_datatype
#define __nvapi_deprecated_datatype(FirstRelease) __declspec(deprecated("Do not use this data type - it is deprecated in release " #FirstRelease "."))
#endif
#else
#ifndef __nvapi_deprecated_function
#define __nvapi_deprecated_function(message)
#endif
#ifndef __nvapi_deprecated_datatype
#define __nvapi_deprecated_datatype(FirstRelease)
#endif
#endif
/* 64-bit types for compilers that support them, plus some obsolete variants */
#if defined(__GNUC__) || defined(__arm) || defined(__IAR_SYSTEMS_ICC__) || defined(__ghs__) || defined(_WIN64)
typedef unsigned long long NvU64; /* 0 to 18446744073709551615 */
typedef long long NvS64; /* -9223372036854775808 to 9223372036854775807 */
#else
typedef unsigned __int64 NvU64; /* 0 to 18446744073709551615 */
typedef __int64 NvS64; /* -9223372036854775808 to 9223372036854775807 */
#endif
#if NVAPI_USE_STDINT
typedef uint32_t NvV32; /* "void": enumerated or multiple fields */
typedef uint32_t NvU32; /* 0 to 4294967295 */
typedef int32_t NvS32; /* -2147483648 to 2147483647 */
#else
// mac os 32-bit still needs this
#if (defined(macintosh) || defined(__APPLE__)) && !defined(__LP64__)
typedef signed long NvS32; /* -2147483648 to 2147483647 */
#else
typedef signed int NvS32; /* -2147483648 to 2147483647 */
#endif
#if !(NVOS_IS_UNIX || (defined(__unix)))
// mac os 32-bit still needs this
#if ( (defined(macintosh) && defined(__LP64__) && (__NVAPI_RESERVED0__)) || \
(!defined(macintosh) && defined(__NVAPI_RESERVED0__)) )
typedef unsigned int NvU32; /* 0 to 4294967295 */
#else
typedef unsigned long NvU32; /* 0 to 4294967295 */
#endif
#else
typedef unsigned int NvU32; /* 0 to 4294967295 */
#endif
#endif
typedef unsigned long temp_NvU32; /* 0 to 4294967295 */
typedef signed short NvS16;
typedef unsigned short NvU16;
typedef unsigned char NvU8;
typedef signed char NvS8;
typedef float NvF32;
typedef double NvF64;
/*!
* Macro to convert NvU32 to NvF32.
*/
#define NvU32TONvF32(_pData) *(NvF32 *)(_pData)
/*!
* Macro to convert NvF32 to NvU32.
*/
#define NvF32TONvU32(_pData) *(NvU32 *)(_pData)
/* Boolean type */
typedef NvU8 NvBool;
#define NV_TRUE ((NvBool)(0 == 0))
#define NV_FALSE ((NvBool)(0 != 0))
typedef struct _NV_RECT
{
NvU32 left;
NvU32 top;
NvU32 right;
NvU32 bottom;
} NV_RECT;
#define NV_DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
//! \addtogroup nvapihandles
//! NVAPI Handles - These handles are retrieved from various calls and passed in to others in NvAPI
//! These are meant to be opaque types. Do not assume they correspond to indices, HDCs,
//! display indexes or anything else.
//!
//! Most handles remain valid until a display re-configuration (display mode set) or GPU
//! reconfiguration (going into or out of SLI modes) occurs. If NVAPI_HANDLE_INVALIDATED
//! is received by an app, it should discard all handles, and re-enumerate them.
//! @{
NV_DECLARE_HANDLE(NvLogicalGpuHandle); //!< One or more physical GPUs acting in concert (SLI)
NV_DECLARE_HANDLE(NvPhysicalGpuHandle); //!< A single physical GPU
NV_DECLARE_HANDLE(NvDisplayHandle); //!< Display Device driven by NVIDIA GPU(s) (an attached display)
NV_DECLARE_HANDLE(NvMonitorHandle); //!< Monitor handle
NV_DECLARE_HANDLE(NvUnAttachedDisplayHandle); //!< Unattached Display Device driven by NVIDIA GPU(s)
NV_DECLARE_HANDLE(NvVisualComputingDeviceHandle); //!< A handle to a Visual Computing Device
NV_DECLARE_HANDLE(NvEventHandle); //!< A handle to an event registration instance
NV_DECLARE_HANDLE(NvHICHandle); //!< A handle to a Host Interface Card
NV_DECLARE_HANDLE(NvGSyncDeviceHandle); //!< A handle to a Sync device
NV_DECLARE_HANDLE(NvVioHandle); //!< A handle to an SDI device
NV_DECLARE_HANDLE(NvTransitionHandle); //!< A handle to address a single transition request
NV_DECLARE_HANDLE(NvAudioHandle); //!< NVIDIA HD Audio Device
NV_DECLARE_HANDLE(Nv3DVPContextHandle); //!< A handle for a 3D Vision Pro (3DVP) context
NV_DECLARE_HANDLE(Nv3DVPTransceiverHandle); //!< A handle for a 3DVP RF transceiver
NV_DECLARE_HANDLE(Nv3DVPGlassesHandle); //!< A handle for a pair of 3DVP RF shutter glasses
NV_DECLARE_HANDLE(NvPcfClientHandle); //!< A handle for NVPCF clients
typedef void* StereoHandle; //!< A stereo handle, that corresponds to the device interface
NV_DECLARE_HANDLE(NvSourceHandle); //!< Unique source handle on the system
NV_DECLARE_HANDLE(NvTargetHandle); //!< Unique target handle on the system
NV_DECLARE_HANDLE(NVDX_SwapChainHandle); //!< DirectX SwapChain objects
static const NVDX_SwapChainHandle NVDX_SWAPCHAIN_NONE = 0;
NV_DECLARE_HANDLE(NvPresentBarrierClientHandle); //!< PresentBarrier client object
//! @}
//! \ingroup nvapihandles
//! @{
#define NVAPI_DEFAULT_HANDLE 0
#define NV_BIT(x) (1 << (x))
//! @}
//! \addtogroup nvapitypes
//! @{
#define NVAPI_GENERIC_STRING_MAX 4096
#define NVAPI_LONG_STRING_MAX 256
#define NVAPI_SHORT_STRING_MAX 64
typedef struct
{
NvS32 sX;
NvS32 sY;
NvS32 sWidth;
NvS32 sHeight;
} NvSBox;
#ifndef NvGUID_Defined
#define NvGUID_Defined
typedef struct
{
NvU32 data1;
NvU16 data2;
NvU16 data3;
NvU8 data4[8];
} NvGUID, NvLUID;
#endif //#ifndef NvGUID_Defined
#define NVAPI_MAX_PHYSICAL_GPUS 64
#define NVAPI_MAX_PHYSICAL_BRIDGES 100
#define NVAPI_PHYSICAL_GPUS 32
#define NVAPI_MAX_LOGICAL_GPUS 64
#define NVAPI_MAX_AVAILABLE_GPU_TOPOLOGIES 256
#define NVAPI_MAX_AVAILABLE_SLI_GROUPS 256
#define NVAPI_MAX_GPU_TOPOLOGIES NVAPI_MAX_PHYSICAL_GPUS
#define NVAPI_MAX_GPU_PER_TOPOLOGY 8
#define NVAPI_MAX_DISPLAY_HEADS 2
#define NVAPI_ADVANCED_DISPLAY_HEADS 4
#define NVAPI_MAX_DISPLAYS NVAPI_PHYSICAL_GPUS * NVAPI_ADVANCED_DISPLAY_HEADS
#define NVAPI_MAX_ACPI_IDS 16
#define NVAPI_MAX_VIEW_MODES 8
#define NVAPI_SYSTEM_MAX_HWBCS 128
#define NVAPI_SYSTEM_HWBC_INVALID_ID 0xffffffff
#define NVAPI_SYSTEM_MAX_DISPLAYS NVAPI_MAX_PHYSICAL_GPUS * NV_MAX_HEADS
#define NV_MAX_HEADS 4 //!< Maximum heads, each with NVAPI_DESKTOP_RES resolution
#define NVAPI_MAX_HEADS_PER_GPU 32
#define NV_MAX_VID_STREAMS 4 //!< Maximum number of input video streams, each with a #NVAPI_VIDEO_SRC_INFO
#define NV_MAX_VID_STREAMS_EX 20 //!< Increasing MAX no. of input video streams, each with a #NVAPI_VIDEO_SRC_INFO
#define NV_MAX_VID_PROFILES 4 //!< Maximum number of output video profiles supported
#define NVAPI_MAX_AUDIO_DEVICES 16
typedef char NvAPI_String[NVAPI_GENERIC_STRING_MAX];
typedef char NvAPI_LongString[NVAPI_LONG_STRING_MAX];
typedef char NvAPI_ShortString[NVAPI_SHORT_STRING_MAX];
typedef NvU16 NvAPI_UnicodeShortString[NVAPI_SHORT_STRING_MAX];
//! @}
// =========================================================================================
//! NvAPI Version Definition \n
//! Maintain per structure specific version define using the MAKE_NVAPI_VERSION macro. \n
//! Usage: #define NV_GENLOCK_STATUS_VER MAKE_NVAPI_VERSION(NV_GENLOCK_STATUS, 1)
//! \ingroup nvapitypes
// =========================================================================================
#define MAKE_NVAPI_VERSION(typeName,ver) (NvU32)(sizeof(typeName) | ((ver)<<16))
//! \ingroup nvapitypes
#define GET_NVAPI_VERSION(ver) (NvU32)((ver)>>16)
//! \ingroup nvapitypes
#define GET_NVAPI_SIZE(ver) (NvU32)((ver) & 0xffff)
// ====================================================
//! NvAPI Status Values
//! All NvAPI functions return one of these codes.
//! \ingroup nvapistatus
// ====================================================
typedef enum _NvAPI_Status
{
NVAPI_OK = 0, //!< Success. Request is completed.
NVAPI_ERROR = -1, //!< Generic error
NVAPI_LIBRARY_NOT_FOUND = -2, //!< NVAPI support library cannot be loaded.
NVAPI_NO_IMPLEMENTATION = -3, //!< not implemented in current driver installation
NVAPI_API_NOT_INITIALIZED = -4, //!< NvAPI_Initialize has not been called (successfully)
NVAPI_INVALID_ARGUMENT = -5, //!< The argument/parameter value is not valid or NULL.
NVAPI_NVIDIA_DEVICE_NOT_FOUND = -6, //!< No NVIDIA display driver, or NVIDIA GPU driving a display, was found.
NVAPI_END_ENUMERATION = -7, //!< No more items to enumerate
NVAPI_INVALID_HANDLE = -8, //!< Invalid handle
NVAPI_INCOMPATIBLE_STRUCT_VERSION = -9, //!< An argument's structure version is not supported
NVAPI_HANDLE_INVALIDATED = -10, //!< The handle is no longer valid (likely due to GPU or display re-configuration)
NVAPI_OPENGL_CONTEXT_NOT_CURRENT = -11, //!< No NVIDIA OpenGL context is current (but needs to be)
NVAPI_INVALID_POINTER = -14, //!< An invalid pointer, usually NULL, was passed as a parameter
NVAPI_NO_GL_EXPERT = -12, //!< OpenGL Expert is not supported by the current drivers
NVAPI_INSTRUMENTATION_DISABLED = -13, //!< OpenGL Expert is supported, but driver instrumentation is currently disabled
NVAPI_NO_GL_NSIGHT = -15, //!< OpenGL does not support Nsight
NVAPI_EXPECTED_LOGICAL_GPU_HANDLE = -100, //!< Expected a logical GPU handle for one or more parameters
NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE = -101, //!< Expected a physical GPU handle for one or more parameters
NVAPI_EXPECTED_DISPLAY_HANDLE = -102, //!< Expected an NV display handle for one or more parameters
NVAPI_INVALID_COMBINATION = -103, //!< The combination of parameters is not valid.
NVAPI_NOT_SUPPORTED = -104, //!< Requested feature is not supported in the selected GPU
NVAPI_PORTID_NOT_FOUND = -105, //!< No port ID was found for the I2C transaction
NVAPI_EXPECTED_UNATTACHED_DISPLAY_HANDLE = -106, //!< Expected an unattached display handle as one of the input parameters.
NVAPI_INVALID_PERF_LEVEL = -107, //!< Invalid perf level
NVAPI_DEVICE_BUSY = -108, //!< Device is busy; request not fulfilled
NVAPI_NV_PERSIST_FILE_NOT_FOUND = -109, //!< NV persist file is not found
NVAPI_PERSIST_DATA_NOT_FOUND = -110, //!< NV persist data is not found
NVAPI_EXPECTED_TV_DISPLAY = -111, //!< Expected a TV output display
NVAPI_EXPECTED_TV_DISPLAY_ON_DCONNECTOR = -112, //!< Expected a TV output on the D Connector - HDTV_EIAJ4120.
NVAPI_NO_ACTIVE_SLI_TOPOLOGY = -113, //!< SLI is not active on this device.
NVAPI_SLI_RENDERING_MODE_NOTALLOWED = -114, //!< Setup of SLI rendering mode is not possible right now.
NVAPI_EXPECTED_DIGITAL_FLAT_PANEL = -115, //!< Expected a digital flat panel.
NVAPI_ARGUMENT_EXCEED_MAX_SIZE = -116, //!< Argument exceeds the expected size.
NVAPI_DEVICE_SWITCHING_NOT_ALLOWED = -117, //!< Inhibit is ON due to one of the flags in NV_GPU_DISPLAY_CHANGE_INHIBIT or SLI active.
NVAPI_TESTING_CLOCKS_NOT_SUPPORTED = -118, //!< Testing of clocks is not supported.
NVAPI_UNKNOWN_UNDERSCAN_CONFIG = -119, //!< The specified underscan config is from an unknown source (e.g. INF)
NVAPI_TIMEOUT_RECONFIGURING_GPU_TOPO = -120, //!< Timeout while reconfiguring GPUs
NVAPI_DATA_NOT_FOUND = -121, //!< Requested data was not found
NVAPI_EXPECTED_ANALOG_DISPLAY = -122, //!< Expected an analog display
NVAPI_NO_VIDLINK = -123, //!< No SLI video bridge is present
NVAPI_REQUIRES_REBOOT = -124, //!< NVAPI requires a reboot for the settings to take effect
NVAPI_INVALID_HYBRID_MODE = -125, //!< The function is not supported with the current Hybrid mode.
NVAPI_MIXED_TARGET_TYPES = -126, //!< The target types are not all the same
NVAPI_SYSWOW64_NOT_SUPPORTED = -127, //!< The function is not supported from 32-bit on a 64-bit system.
NVAPI_IMPLICIT_SET_GPU_TOPOLOGY_CHANGE_NOT_ALLOWED = -128, //!< There is no implicit GPU topology active. Use NVAPI_SetHybridMode to change topology.
NVAPI_REQUEST_USER_TO_CLOSE_NON_MIGRATABLE_APPS = -129, //!< Prompt the user to close all non-migratable applications.
NVAPI_OUT_OF_MEMORY = -130, //!< Could not allocate sufficient memory to complete the call.
NVAPI_WAS_STILL_DRAWING = -131, //!< The previous operation that is transferring information to or from this surface is incomplete.
NVAPI_FILE_NOT_FOUND = -132, //!< The file was not found.
NVAPI_TOO_MANY_UNIQUE_STATE_OBJECTS = -133, //!< There are too many unique instances of a particular type of state object.
NVAPI_INVALID_CALL = -134, //!< The method call is invalid. For example, a method's parameter may not be a valid pointer.
NVAPI_D3D10_1_LIBRARY_NOT_FOUND = -135, //!< d3d10_1.dll cannot be loaded.
NVAPI_FUNCTION_NOT_FOUND = -136, //!< Couldn't find the function in the loaded DLL.
NVAPI_INVALID_USER_PRIVILEGE = -137, //!< The application will require Administrator privileges to access this API.
//!< The application can be elevated to a higher permission level by selecting "Run as Administrator".
NVAPI_EXPECTED_NON_PRIMARY_DISPLAY_HANDLE = -138, //!< The handle corresponds to GDIPrimary.
NVAPI_EXPECTED_COMPUTE_GPU_HANDLE = -139, //!< Setting Physx GPU requires that the GPU is compute-capable.
NVAPI_STEREO_NOT_INITIALIZED = -140, //!< The Stereo part of NVAPI failed to initialize completely. Check if the stereo driver is installed.
NVAPI_STEREO_REGISTRY_ACCESS_FAILED = -141, //!< Access to stereo-related registry keys or values has failed.
NVAPI_STEREO_REGISTRY_PROFILE_TYPE_NOT_SUPPORTED = -142, //!< The given registry profile type is not supported.
NVAPI_STEREO_REGISTRY_VALUE_NOT_SUPPORTED = -143, //!< The given registry value is not supported.
NVAPI_STEREO_NOT_ENABLED = -144, //!< Stereo is not enabled and the function needed it to execute completely.
NVAPI_STEREO_NOT_TURNED_ON = -145, //!< Stereo is not turned on and the function needed it to execute completely.
NVAPI_STEREO_INVALID_DEVICE_INTERFACE = -146, //!< Invalid device interface.
NVAPI_STEREO_PARAMETER_OUT_OF_RANGE = -147, //!< Separation percentage or JPEG image capture quality is out of [0-100] range.
NVAPI_STEREO_FRUSTUM_ADJUST_MODE_NOT_SUPPORTED = -148, //!< The given frustum adjust mode is not supported.
NVAPI_TOPO_NOT_POSSIBLE = -149, //!< The mosaic topology is not possible given the current state of the hardware.
NVAPI_MODE_CHANGE_FAILED = -150, //!< An attempt to do a display resolution mode change has failed.
NVAPI_D3D11_LIBRARY_NOT_FOUND = -151, //!< d3d11.dll/d3d11_beta.dll cannot be loaded.
NVAPI_INVALID_ADDRESS = -152, //!< Address is outside of valid range.
NVAPI_STRING_TOO_SMALL = -153, //!< The pre-allocated string is too small to hold the result.
NVAPI_MATCHING_DEVICE_NOT_FOUND = -154, //!< The input does not match any of the available devices.
NVAPI_DRIVER_RUNNING = -155, //!< Driver is running.
NVAPI_DRIVER_NOTRUNNING = -156, //!< Driver is not running.
NVAPI_ERROR_DRIVER_RELOAD_REQUIRED = -157, //!< A driver reload is required to apply these settings.
NVAPI_SET_NOT_ALLOWED = -158, //!< Intended setting is not allowed.
NVAPI_ADVANCED_DISPLAY_TOPOLOGY_REQUIRED = -159, //!< Information can't be returned due to "advanced display topology".
NVAPI_SETTING_NOT_FOUND = -160, //!< Setting is not found.
NVAPI_SETTING_SIZE_TOO_LARGE = -161, //!< Setting size is too large.
NVAPI_TOO_MANY_SETTINGS_IN_PROFILE = -162, //!< There are too many settings for a profile.
NVAPI_PROFILE_NOT_FOUND = -163, //!< Profile is not found.
NVAPI_PROFILE_NAME_IN_USE = -164, //!< Profile name is duplicated.
NVAPI_PROFILE_NAME_EMPTY = -165, //!< Profile name is empty.
NVAPI_EXECUTABLE_NOT_FOUND = -166, //!< Application not found in the Profile.
NVAPI_EXECUTABLE_ALREADY_IN_USE = -167, //!< Application already exists in the other profile.
NVAPI_DATATYPE_MISMATCH = -168, //!< Data Type mismatch
NVAPI_PROFILE_REMOVED = -169, //!< The profile passed as parameter has been removed and is no longer valid.
NVAPI_UNREGISTERED_RESOURCE = -170, //!< An unregistered resource was passed as a parameter.
NVAPI_ID_OUT_OF_RANGE = -171, //!< The DisplayId corresponds to a display which is not within the normal outputId range.
NVAPI_DISPLAYCONFIG_VALIDATION_FAILED = -172, //!< Display topology is not valid so the driver cannot do a mode set on this configuration.
NVAPI_DPMST_CHANGED = -173, //!< Display Port Multi-Stream topology has been changed.
NVAPI_INSUFFICIENT_BUFFER = -174, //!< Input buffer is insufficient to hold the contents.
NVAPI_ACCESS_DENIED = -175, //!< No access to the caller.
NVAPI_MOSAIC_NOT_ACTIVE = -176, //!< The requested action cannot be performed without Mosaic being enabled.
NVAPI_SHARE_RESOURCE_RELOCATED = -177, //!< The surface is relocated away from video memory.
NVAPI_REQUEST_USER_TO_DISABLE_DWM = -178, //!< The user should disable DWM before calling NvAPI.
NVAPI_D3D_DEVICE_LOST = -179, //!< D3D device status is D3DERR_DEVICELOST or D3DERR_DEVICENOTRESET - the user has to reset the device.
NVAPI_INVALID_CONFIGURATION = -180, //!< The requested action cannot be performed in the current state.
NVAPI_STEREO_HANDSHAKE_NOT_DONE = -181, //!< Call failed as stereo handshake not completed.
NVAPI_EXECUTABLE_PATH_IS_AMBIGUOUS = -182, //!< The path provided was too short to determine the correct NVDRS_APPLICATION
NVAPI_DEFAULT_STEREO_PROFILE_IS_NOT_DEFINED = -183, //!< Default stereo profile is not currently defined
NVAPI_DEFAULT_STEREO_PROFILE_DOES_NOT_EXIST = -184, //!< Default stereo profile does not exist
NVAPI_CLUSTER_ALREADY_EXISTS = -185, //!< A cluster is already defined with the given configuration.
NVAPI_DPMST_DISPLAY_ID_EXPECTED = -186, //!< The input display id is not that of a multi stream enabled connector or a display device in a multi stream topology
NVAPI_INVALID_DISPLAY_ID = -187, //!< The input display id is not valid or the monitor associated to it does not support the current operation
NVAPI_STREAM_IS_OUT_OF_SYNC = -188, //!< While playing secure audio stream, stream goes out of sync
NVAPI_INCOMPATIBLE_AUDIO_DRIVER = -189, //!< Older audio driver version than required
NVAPI_VALUE_ALREADY_SET = -190, //!< Value already set, setting again not allowed.
NVAPI_TIMEOUT = -191, //!< Requested operation timed out
NVAPI_GPU_WORKSTATION_FEATURE_INCOMPLETE = -192, //!< The requested workstation feature set has incomplete driver internal allocation resources
NVAPI_STEREO_INIT_ACTIVATION_NOT_DONE = -193, //!< Call failed because InitActivation was not called.
NVAPI_SYNC_NOT_ACTIVE = -194, //!< The requested action cannot be performed without Sync being enabled.
NVAPI_SYNC_MASTER_NOT_FOUND = -195, //!< The requested action cannot be performed without Sync Master being enabled.
NVAPI_INVALID_SYNC_TOPOLOGY = -196, //!< Invalid displays passed in the NV_GSYNC_DISPLAY pointer.
NVAPI_ECID_SIGN_ALGO_UNSUPPORTED = -197, //!< The specified signing algorithm is not supported. Either an incorrect value was entered or the current installed driver/hardware does not support the input value.
NVAPI_ECID_KEY_VERIFICATION_FAILED = -198, //!< The encrypted public key verification has failed.
NVAPI_FIRMWARE_OUT_OF_DATE = -199, //!< The device's firmware is out of date.
NVAPI_FIRMWARE_REVISION_NOT_SUPPORTED = -200, //!< The device's firmware is not supported.
NVAPI_LICENSE_CALLER_AUTHENTICATION_FAILED = -201, //!< The caller is not authorized to modify the License.
NVAPI_D3D_DEVICE_NOT_REGISTERED = -202, //!< The user tried to use a deferred context without registering the device first
NVAPI_RESOURCE_NOT_ACQUIRED = -203, //!< Head or SourceId was not reserved for the VR Display before doing the Modeset or the dedicated display.
NVAPI_TIMING_NOT_SUPPORTED = -204, //!< Provided timing is not supported.
NVAPI_HDCP_ENCRYPTION_FAILED = -205, //!< HDCP Encryption Failed for the device. Would be applicable when the device is HDCP Capable.
NVAPI_PCLK_LIMITATION_FAILED = -206, //!< Provided mode is over sink device pclk limitation.
NVAPI_NO_CONNECTOR_FOUND = -207, //!< No connector on GPU found.
NVAPI_HDCP_DISABLED = -208, //!< When a non-HDCP capable HMD is connected, we would inform user by this code.
NVAPI_API_IN_USE = -209, //!< Atleast an API is still being called
NVAPI_NVIDIA_DISPLAY_NOT_FOUND = -210, //!< No display found on Nvidia GPU(s).
NVAPI_PRIV_SEC_VIOLATION = -211, //!< Priv security violation, improper access to a secured register.
NVAPI_INCORRECT_VENDOR = -212, //!< NVAPI cannot be called by this vendor
NVAPI_DISPLAY_IN_USE = -213, //!< DirectMode Display is already in use
NVAPI_UNSUPPORTED_CONFIG_NON_HDCP_HMD = -214, //!< The Config is having Non-NVidia GPU with Non-HDCP HMD connected
NVAPI_MAX_DISPLAY_LIMIT_REACHED = -215, //!< GPU's Max Display Limit has Reached
NVAPI_INVALID_DIRECT_MODE_DISPLAY = -216, //!< DirectMode not Enabled on the Display
NVAPI_GPU_IN_DEBUG_MODE = -217, //!< GPU is in debug mode, OC is NOT allowed.
NVAPI_D3D_CONTEXT_NOT_FOUND = -218, //!< No NvAPI context was found for this D3D object
NVAPI_STEREO_VERSION_MISMATCH = -219, //!< there is version mismatch between stereo driver and dx driver
NVAPI_GPU_NOT_POWERED = -220, //!< GPU is not powered and so the request cannot be completed.
NVAPI_ERROR_DRIVER_RELOAD_IN_PROGRESS = -221, //!< The display driver update in progress.
NVAPI_WAIT_FOR_HW_RESOURCE = -222, //!< Wait for HW resources allocation
NVAPI_REQUIRE_FURTHER_HDCP_ACTION = -223, //!< operation requires further HDCP action
NVAPI_DISPLAY_MUX_TRANSITION_FAILED = -224, //!< Dynamic Mux transition failure
NVAPI_INVALID_DSC_VERSION = -225, //!< Invalid DSC version
NVAPI_INVALID_DSC_SLICECOUNT = -226, //!< Invalid DSC slice count
NVAPI_INVALID_DSC_OUTPUT_BPP = -227, //!< Invalid DSC output BPP
NVAPI_FAILED_TO_LOAD_FROM_DRIVER_STORE = -228, //!< There was an error while loading nvapi.dll from the driver store.
NVAPI_NO_VULKAN = -229, //!< OpenGL does not export Vulkan fake extensions
NVAPI_REQUEST_PENDING = -230, //!< A request for NvTOPPs telemetry CData has already been made and is pending a response.
NVAPI_RESOURCE_IN_USE = -231, //!< Operation cannot be performed because the resource is in use.
NVAPI_INVALID_IMAGE = -232, //!< Device kernel image is invalid
NVAPI_INVALID_PTX = -233, //!< PTX JIT compilation failed
NVAPI_NVLINK_UNCORRECTABLE = -234, //!< Uncorrectable NVLink error was detected during the execution
NVAPI_JIT_COMPILER_NOT_FOUND = -235, //!< PTX JIT compiler library was not found.
NVAPI_INVALID_SOURCE = -236, //!< Device kernel source is invalid.
NVAPI_ILLEGAL_INSTRUCTION = -237, //!< While executing a kernel, the device encountered an illegal instruction.
NVAPI_INVALID_PC = -238, //!< While executing a kernel, the device program counter wrapped its address space
NVAPI_LAUNCH_FAILED = -239, //!< An exception occurred on the device while executing a kernel
NVAPI_NOT_PERMITTED = -240, //!< Attempted operation is not permitted.
NVAPI_CALLBACK_ALREADY_REGISTERED = -241, //!< The callback function has already been registered.
NVAPI_CALLBACK_NOT_FOUND = -242, //!< The callback function is not found or not registered.
NVAPI_INVALID_OUTPUT_WIRE_FORMAT = -243, //!< Invalid Wire Format for the VR HMD
} NvAPI_Status;
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_SYS_GetDriverAndBranchVersion
//
//! DESCRIPTION: This API returns display driver version and driver-branch string.
//!
//! SUPPORTED OS: Windows 10 and higher
//!
//!
//! \param [out] pDriverVersion Contains the driver version after successful return.
//! \param [out] szBuildBranchString Contains the driver-branch string after successful return.
//!
//! \retval ::NVAPI_INVALID_ARGUMENT: either pDriverVersion is NULL or enum index too big
//! \retval ::NVAPI_OK - completed request
//! \retval ::NVAPI_API_NOT_INTIALIZED - NVAPI not initialized
//! \retval ::NVAPI_ERROR - miscellaneous error occurred
//!
//! \ingroup driverapi
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_SYS_GetDriverAndBranchVersion(NvU32* pDriverVersion, NvAPI_ShortString szBuildBranchString);
//! \ingroup driverapi
//! Used in NvAPI_GPU_GetMemoryInfo().
typedef struct
{
NvU32 version; //!< Version info
NvU32 dedicatedVideoMemory; //!< Size(in kb) of the physical framebuffer.
NvU32 availableDedicatedVideoMemory; //!< Size(in kb) of the available physical framebuffer for allocating video memory surfaces.
NvU32 systemVideoMemory; //!< Size(in kb) of system memory the driver allocates at load time.
NvU32 sharedSystemMemory; //!< Size(in kb) of shared system memory that driver is allowed to commit for surfaces across all allocations.
} NV_DISPLAY_DRIVER_MEMORY_INFO_V1;
//! \ingroup driverapi
//! Used in NvAPI_GPU_GetMemoryInfo().
typedef struct
{
NvU32 version; //!< Version info
NvU32 dedicatedVideoMemory; //!< Size(in kb) of the physical framebuffer.
NvU32 availableDedicatedVideoMemory; //!< Size(in kb) of the available physical framebuffer for allocating video memory surfaces.
NvU32 systemVideoMemory; //!< Size(in kb) of system memory the driver allocates at load time.
NvU32 sharedSystemMemory; //!< Size(in kb) of shared system memory that driver is allowed to commit for surfaces across all allocations.
NvU32 curAvailableDedicatedVideoMemory; //!< Size(in kb) of the current available physical framebuffer for allocating video memory surfaces.
} NV_DISPLAY_DRIVER_MEMORY_INFO_V2;
//! \ingroup driverapi
//! Used in NvAPI_GPU_GetMemoryInfo().
typedef struct
{
NvU32 version; //!< Version info
NvU32 dedicatedVideoMemory; //!< Size(in kb) of the physical framebuffer.
NvU32 availableDedicatedVideoMemory; //!< Size(in kb) of the available physical framebuffer for allocating video memory surfaces.
NvU32 systemVideoMemory; //!< Size(in kb) of system memory the driver allocates at load time.
NvU32 sharedSystemMemory; //!< Size(in kb) of shared system memory that driver is allowed to commit for surfaces across all allocations.
NvU32 curAvailableDedicatedVideoMemory; //!< Size(in kb) of the current available physical framebuffer for allocating video memory surfaces.
NvU32 dedicatedVideoMemoryEvictionsSize; //!< Size(in kb) of the total size of memory released as a result of the evictions.
NvU32 dedicatedVideoMemoryEvictionCount; //!< Indicates the number of eviction events that caused an allocation to be removed from dedicated video memory to free GPU
//!< video memory to make room for other allocations.
} NV_DISPLAY_DRIVER_MEMORY_INFO_V3;
//! \ingroup driverapi
typedef NV_DISPLAY_DRIVER_MEMORY_INFO_V3 NV_DISPLAY_DRIVER_MEMORY_INFO;
//! \ingroup driverapi
//! Macro for constructing the version field of NV_DISPLAY_DRIVER_MEMORY_INFO_V1
#define NV_DISPLAY_DRIVER_MEMORY_INFO_VER_1 MAKE_NVAPI_VERSION(NV_DISPLAY_DRIVER_MEMORY_INFO_V1,1)
//! \ingroup driverapi
//! Macro for constructing the version field of NV_DISPLAY_DRIVER_MEMORY_INFO_V2
#define NV_DISPLAY_DRIVER_MEMORY_INFO_VER_2 MAKE_NVAPI_VERSION(NV_DISPLAY_DRIVER_MEMORY_INFO_V2,2)
//! \ingroup driverapi
//! Macro for constructing the version field of NV_DISPLAY_DRIVER_MEMORY_INFO_V3
#define NV_DISPLAY_DRIVER_MEMORY_INFO_VER_3 MAKE_NVAPI_VERSION(NV_DISPLAY_DRIVER_MEMORY_INFO_V3,3)
//! \ingroup driverapi
#define NV_DISPLAY_DRIVER_MEMORY_INFO_VER NV_DISPLAY_DRIVER_MEMORY_INFO_VER_3
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_GPU_GetMemoryInfo
//
//! DESCRIPTION: This function retrieves the available driver memory footprint for the specified GPU.
//! If the GPU is in TCC Mode, only dedicatedVideoMemory will be returned in pMemoryInfo (NV_DISPLAY_DRIVER_MEMORY_INFO).
//!
//! \deprecated Do not use this function - it is deprecated in release 520. Instead, use NvAPI_GPU_GetMemoryInfoEx.
//! SUPPORTED OS: Windows 10 and higher
//!
//!
//! TCC_SUPPORTED
//!
//! \since Release: 177
//!
//! \param [in] hPhysicalGpu Handle of the physical GPU for which the memory information is to be extracted.
//! \param [out] pMemoryInfo The memory footprint available in the driver. See NV_DISPLAY_DRIVER_MEMORY_INFO.
//!
//! \retval NVAPI_INVALID_ARGUMENT pMemoryInfo is NULL.
//! \retval NVAPI_OK Call successful.
//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found.
//! \retval NVAPI_INCOMPATIBLE_STRUCT_VERSION NV_DISPLAY_DRIVER_MEMORY_INFO structure version mismatch.
//!
//! \ingroup driverapi
///////////////////////////////////////////////////////////////////////////////
__nvapi_deprecated_function("Do not use this function - it is deprecated in release 520. Instead, use NvAPI_GPU_GetMemoryInfoEx.")
NVAPI_INTERFACE NvAPI_GPU_GetMemoryInfo(NvPhysicalGpuHandle hPhysicalGpu, NV_DISPLAY_DRIVER_MEMORY_INFO *pMemoryInfo);
//! \ingroup driverapi
//! Used in NvAPI_GPU_GetMemoryInfoEx().
typedef struct
{
NvU32 version; //!< Structure version
NvU64 dedicatedVideoMemory; //!< Size(in bytes) of the physical framebuffer. Refers to the dedicated video memory on discrete GPUs.
//! It is more performant for GPU operations than the reserved systemVideoMemory.
NvU64 availableDedicatedVideoMemory; //!< Size(in bytes) of the available physical framebuffer for allocating video memory surfaces.
NvU64 systemVideoMemory; //!< Size(in bytes) of system memory the driver allocates at load time. It is a substitute for dedicated video memory.
//!< Typically used with integrated GPUs that do not have dedicated video memory.
NvU64 sharedSystemMemory; //!< Size(in bytes) of shared system memory that driver is allowed to commit for surfaces across all allocations.
//!< On discrete GPUs, it is used to utilize system memory for various operations. It does not need to be reserved during boot.
//!< It may be used by both GPU and CPU, and has an "on-demand" type of usage.
NvU64 curAvailableDedicatedVideoMemory; //!< Size(in bytes) of the current available physical framebuffer for allocating video memory surfaces.
NvU64 dedicatedVideoMemoryEvictionsSize; //!< Size(in bytes) of the total size of memory released as a result of the evictions.
NvU64 dedicatedVideoMemoryEvictionCount; //!< Indicates the number of eviction events that caused an allocation to be removed from dedicated video memory to free GPU
//!< video memory to make room for other allocations.
NvU64 dedicatedVideoMemoryPromotionsSize; //!< Size(in bytes) of the total size of memory allocated as a result of the promotions.
NvU64 dedicatedVideoMemoryPromotionCount; //!< Indicates the number of promotion events that caused an allocation to be promoted to dedicated video memory
} NV_GPU_MEMORY_INFO_EX_V1;
//! \ingroup driverapi
typedef NV_GPU_MEMORY_INFO_EX_V1 NV_GPU_MEMORY_INFO_EX;
//! \ingroup driverapi
//! Macro for constructing the version field of NV_GPU_MEMORY_INFO_EX_V1
#define NV_GPU_MEMORY_INFO_EX_VER_1 MAKE_NVAPI_VERSION(NV_GPU_MEMORY_INFO_EX_V1,1)
//! \ingroup driverapi
#define NV_GPU_MEMORY_INFO_EX_VER NV_GPU_MEMORY_INFO_EX_VER_1
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_GPU_GetMemoryInfoEx
//
//! DESCRIPTION: This function retrieves the available driver memory footprint for the specified GPU.
//! If the GPU is in TCC Mode, only dedicatedVideoMemory will be returned in pMemoryInfo (NV_GPU_MEMORY_INFO_EX).
//!
//! SUPPORTED OS: Windows 10 and higher
//!
//!
//! TCC_SUPPORTED
//!
//! MCDM_SUPPORTED
//!
//! \since Release: 520
//!
//! \param [in] hPhysicalGpu Handle of the physical GPU for which the memory information is to be extracted.
//! \param [out] pMemoryInfo The memory footprint available in the driver. See NV_GPU_MEMORY_INFO_EX.
//!
//! \retval NVAPI_INVALID_ARGUMENT pMemoryInfo is NULL.
//! \retval NVAPI_OK Call successful.
//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found.
//! \retval NVAPI_INCOMPATIBLE_STRUCT_VERSION NV_GPU_MEMORY_INFO_EX structure version mismatch.
//!
//! \ingroup driverapi
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_GPU_GetMemoryInfoEx(NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_MEMORY_INFO_EX *pMemoryInfo);
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_EnumPhysicalGPUs
//
//! This function returns an array of physical GPU handles.
//! Each handle represents a physical GPU present in the system.
//! That GPU may be part of an SLI configuration, or may not be visible to the OS directly.
//!
//! At least one GPU must be present in the system and running an NVIDIA display driver.
//!
//! The array nvGPUHandle will be filled with physical GPU handle values. The returned
//! gpuCount determines how many entries in the array are valid.
//!
//! \note In drivers older than 105.00, all physical GPU handles get invalidated on a
//! modeset. So the calling applications need to renum the handles after every modeset.\n
//! With drivers 105.00 and up, all physical GPU handles are constant.
//! Physical GPU handles are constant as long as the GPUs are not physically moved and
//! the SBIOS VGA order is unchanged.
//!
//! For GPU handles in TCC MODE please use NvAPI_EnumTCCPhysicalGPUs()
//!
//! SUPPORTED OS: Windows 10 and higher
//!
//!
//! \par Introduced in
//! \since Release: 80
//!
//! \retval NVAPI_INVALID_ARGUMENT nvGPUHandle or pGpuCount is NULL
//! \retval NVAPI_OK One or more handles were returned
//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found
//! \ingroup gpu
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_EnumPhysicalGPUs(NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount);
#if defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__) || defined(__d3d12_h__)
NV_DECLARE_HANDLE(NVDX_ObjectHandle); // DX Objects
static const NVDX_ObjectHandle NVDX_OBJECT_NONE = 0;
#endif //if defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__) || defined(__d3d12_h__)
#if defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__) || defined(__d3d12_h__)
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_D3D_GetObjectHandleForResource
//
//! DESCRIPTION: This API gets a handle to a resource.
//!
//! \param [in] pDev The ID3D11Device, ID3D10Device or IDirect3DDevice9 or ID3D11DeviceContext to use
//! \param [in] pResource The ID3D11Resource, ID3D10Resource or IDirect3DResource9 from which
//! we want the NvAPI handle
//! \param [out] pHandle A handle to the resource
//!
//! SUPPORTED OS: Windows 10 and higher
//!
//!
//! \since Release: 185
//!
//! \return ::NVAPI_OK if the handle was populated.
//!
//! \ingroup dx
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_D3D_GetObjectHandleForResource(
IUnknown *pDevice,
IUnknown *pResource,
NVDX_ObjectHandle *pHandle);
#endif //if defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__) || defined(__d3d12_h__)
#include"imports/nvapi/nvapi_lite_salend.h"
#ifdef __cplusplus
}
#endif
#pragma pack(pop)

View File

@@ -0,0 +1,184 @@
/*********************************************************************************************************\
|* *|
|* SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. *|
|* SPDX-License-Identifier: MIT *|
|* *|
|* 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"imports/nvapi/nvapi_lite_salstart.h"
#include"imports/nvapi/nvapi_lite_common.h"
#pragma pack(push,8)
#ifdef __cplusplus
extern "C" {
#endif
#if defined(__cplusplus) && (defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__))
//! \ingroup dx
//! D3D_FEATURE_LEVEL supported - used in NvAPI_D3D11_CreateDevice() and NvAPI_D3D11_CreateDeviceAndSwapChain()
typedef enum
{
NVAPI_DEVICE_FEATURE_LEVEL_NULL = -1,
NVAPI_DEVICE_FEATURE_LEVEL_10_0 = 0,
NVAPI_DEVICE_FEATURE_LEVEL_10_0_PLUS = 1,
NVAPI_DEVICE_FEATURE_LEVEL_10_1 = 2,
NVAPI_DEVICE_FEATURE_LEVEL_11_0 = 3,
} NVAPI_DEVICE_FEATURE_LEVEL;
#endif //defined(__cplusplus) && (defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__))
#if defined(__cplusplus) && defined(__d3d11_h__)
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_D3D11_CreateDevice
//
//! DESCRIPTION: This function tries to create a DirectX 11 device. If the call fails (if we are running
//! on pre-DirectX 11 hardware), depending on the type of hardware it will try to create a DirectX 10.1 OR DirectX 10.0+
//! OR DirectX 10.0 device. The function call is the same as D3D11CreateDevice(), but with an extra
//! argument (D3D_FEATURE_LEVEL supported by the device) that the function fills in. This argument
//! can contain -1 (NVAPI_DEVICE_FEATURE_LEVEL_NULL), if the requested featureLevel is less than DirecX 10.0.
//!
//! NOTE: When NvAPI_D3D11_CreateDevice is called with 10+ feature level we have an issue on few set of
//! tesla hardware (G80/G84/G86/G92/G94/G96) which does not support all feature level 10+ functionality
//! e.g. calling driver with mismatch between RenderTarget and Depth Buffer. App developers should
//! take into consideration such limitation when using NVAPI on such tesla hardwares.
//! SUPPORTED OS: Windows 10 and higher
//!
//!
//! \since Release: 185
//!
//! \param [in] pAdapter
//! \param [in] DriverType
//! \param [in] Software
//! \param [in] Flags
//! \param [in] *pFeatureLevels
//! \param [in] FeatureLevels
//! \param [in] SDKVersion
//! \param [in] **ppDevice
//! \param [in] *pFeatureLevel
//! \param [in] **ppImmediateContext
//! \param [in] *pSupportedLevel D3D_FEATURE_LEVEL supported
//!
//! \return NVAPI_OK if the createDevice call succeeded.
//!
//! \ingroup dx
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_D3D11_CreateDevice(IDXGIAdapter* pAdapter,
D3D_DRIVER_TYPE DriverType,
HMODULE Software,
UINT Flags,
CONST D3D_FEATURE_LEVEL *pFeatureLevels,
UINT FeatureLevels,
UINT SDKVersion,
ID3D11Device **ppDevice,
D3D_FEATURE_LEVEL *pFeatureLevel,
ID3D11DeviceContext **ppImmediateContext,
NVAPI_DEVICE_FEATURE_LEVEL *pSupportedLevel);
#endif //defined(__cplusplus) && defined(__d3d11_h__)
#if defined(__cplusplus) && defined(__d3d11_h__)
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_D3D11_CreateDeviceAndSwapChain
//
//! DESCRIPTION: This function tries to create a DirectX 11 device and swap chain. If the call fails (if we are
//! running on pre=DirectX 11 hardware), depending on the type of hardware it will try to create a DirectX 10.1 OR
//! DirectX 10.0+ OR DirectX 10.0 device. The function call is the same as D3D11CreateDeviceAndSwapChain,
//! but with an extra argument (D3D_FEATURE_LEVEL supported by the device) that the function fills
//! in. This argument can contain -1 (NVAPI_DEVICE_FEATURE_LEVEL_NULL), if the requested featureLevel
//! is less than DirectX 10.0.
//!
//! SUPPORTED OS: Windows 10 and higher
//!
//!
//! \since Release: 185
//!
//! \param [in] pAdapter
//! \param [in] DriverType
//! \param [in] Software
//! \param [in] Flags
//! \param [in] *pFeatureLevels
//! \param [in] FeatureLevels
//! \param [in] SDKVersion
//! \param [in] *pSwapChainDesc
//! \param [in] **ppSwapChain
//! \param [in] **ppDevice
//! \param [in] *pFeatureLevel
//! \param [in] **ppImmediateContext
//! \param [in] *pSupportedLevel D3D_FEATURE_LEVEL supported
//!
//!return NVAPI_OK if the createDevice with swap chain call succeeded.
//!
//! \ingroup dx
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_D3D11_CreateDeviceAndSwapChain(IDXGIAdapter* pAdapter,
D3D_DRIVER_TYPE DriverType,
HMODULE Software,
UINT Flags,
CONST D3D_FEATURE_LEVEL *pFeatureLevels,
UINT FeatureLevels,
UINT SDKVersion,
CONST DXGI_SWAP_CHAIN_DESC *pSwapChainDesc,
IDXGISwapChain **ppSwapChain,
ID3D11Device **ppDevice,
D3D_FEATURE_LEVEL *pFeatureLevel,
ID3D11DeviceContext **ppImmediateContext,
NVAPI_DEVICE_FEATURE_LEVEL *pSupportedLevel);
#endif //defined(__cplusplus) && defined(__d3d11_h__)
#if defined(__cplusplus) && defined(__d3d11_h__)
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_D3D11_SetDepthBoundsTest
//
//! DESCRIPTION: This function enables/disables the depth bounds test
//!
//! SUPPORTED OS: Windows 10 and higher
//!
//!
//! \param [in] pDeviceOrContext The device or device context to set depth bounds test
//! \param [in] bEnable Enable(non-zero)/disable(zero) the depth bounds test
//! \param [in] fMinDepth The minimum depth for depth bounds test
//! \param [in] fMaxDepth The maximum depth for depth bounds test
//! The valid values for fMinDepth and fMaxDepth
//! are such that 0 <= fMinDepth <= fMaxDepth <= 1
//!
//! \return ::NVAPI_OK if the depth bounds test was correcly enabled or disabled
//!
//! \ingroup dx
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_D3D11_SetDepthBoundsTest(IUnknown* pDeviceOrContext,
NvU32 bEnable,
float fMinDepth,
float fMaxDepth);
#endif //defined(__cplusplus) && defined(__d3d11_h__)
#include"imports/nvapi/nvapi_lite_salend.h"
#ifdef __cplusplus
}
#endif
#pragma pack(pop)

View File

@@ -0,0 +1,809 @@
/*********************************************************************************************************\
|* *|
|* SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. *|
|* SPDX-License-Identifier: MIT *|
|* *|
|* 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 __NVAPI_EMPTY_SAL
#ifdef __nvapi_undef__ecount
#undef __ecount
#undef __nvapi_undef__ecount
#endif
#ifdef __nvapi_undef__bcount
#undef __bcount
#undef __nvapi_undef__bcount
#endif
#ifdef __nvapi_undef__in
#undef __in
#undef __nvapi_undef__in
#endif
#ifdef __nvapi_undef__in_ecount
#undef __in_ecount
#undef __nvapi_undef__in_ecount
#endif
#ifdef __nvapi_undef__in_bcount
#undef __in_bcount
#undef __nvapi_undef__in_bcount
#endif
#ifdef __nvapi_undef__in_z
#undef __in_z
#undef __nvapi_undef__in_z
#endif
#ifdef __nvapi_undef__in_ecount_z
#undef __in_ecount_z
#undef __nvapi_undef__in_ecount_z
#endif
#ifdef __nvapi_undef__in_bcount_z
#undef __in_bcount_z
#undef __nvapi_undef__in_bcount_z
#endif
#ifdef __nvapi_undef__in_nz
#undef __in_nz
#undef __nvapi_undef__in_nz
#endif
#ifdef __nvapi_undef__in_ecount_nz
#undef __in_ecount_nz
#undef __nvapi_undef__in_ecount_nz
#endif
#ifdef __nvapi_undef__in_bcount_nz
#undef __in_bcount_nz
#undef __nvapi_undef__in_bcount_nz
#endif
#ifdef __nvapi_undef__out
#undef __out
#undef __nvapi_undef__out
#endif
#ifdef __nvapi_undef__out_ecount
#undef __out_ecount
#undef __nvapi_undef__out_ecount
#endif
#ifdef __nvapi_undef__out_bcount
#undef __out_bcount
#undef __nvapi_undef__out_bcount
#endif
#ifdef __nvapi_undef__out_ecount_part
#undef __out_ecount_part
#undef __nvapi_undef__out_ecount_part
#endif
#ifdef __nvapi_undef__out_bcount_part
#undef __out_bcount_part
#undef __nvapi_undef__out_bcount_part
#endif
#ifdef __nvapi_undef__out_ecount_full
#undef __out_ecount_full
#undef __nvapi_undef__out_ecount_full
#endif
#ifdef __nvapi_undef__out_bcount_full
#undef __out_bcount_full
#undef __nvapi_undef__out_bcount_full
#endif
#ifdef __nvapi_undef__out_z
#undef __out_z
#undef __nvapi_undef__out_z
#endif
#ifdef __nvapi_undef__out_z_opt
#undef __out_z_opt
#undef __nvapi_undef__out_z_opt
#endif
#ifdef __nvapi_undef__out_ecount_z
#undef __out_ecount_z
#undef __nvapi_undef__out_ecount_z
#endif
#ifdef __nvapi_undef__out_bcount_z
#undef __out_bcount_z
#undef __nvapi_undef__out_bcount_z
#endif
#ifdef __nvapi_undef__out_ecount_part_z
#undef __out_ecount_part_z
#undef __nvapi_undef__out_ecount_part_z
#endif
#ifdef __nvapi_undef__out_bcount_part_z
#undef __out_bcount_part_z
#undef __nvapi_undef__out_bcount_part_z
#endif
#ifdef __nvapi_undef__out_ecount_full_z
#undef __out_ecount_full_z
#undef __nvapi_undef__out_ecount_full_z
#endif
#ifdef __nvapi_undef__out_bcount_full_z
#undef __out_bcount_full_z
#undef __nvapi_undef__out_bcount_full_z
#endif
#ifdef __nvapi_undef__out_nz
#undef __out_nz
#undef __nvapi_undef__out_nz
#endif
#ifdef __nvapi_undef__out_nz_opt
#undef __out_nz_opt
#undef __nvapi_undef__out_nz_opt
#endif
#ifdef __nvapi_undef__out_ecount_nz
#undef __out_ecount_nz
#undef __nvapi_undef__out_ecount_nz
#endif
#ifdef __nvapi_undef__out_bcount_nz
#undef __out_bcount_nz
#undef __nvapi_undef__out_bcount_nz
#endif
#ifdef __nvapi_undef__inout
#undef __inout
#undef __nvapi_undef__inout
#endif
#ifdef __nvapi_undef__inout_ecount
#undef __inout_ecount
#undef __nvapi_undef__inout_ecount
#endif
#ifdef __nvapi_undef__inout_bcount
#undef __inout_bcount
#undef __nvapi_undef__inout_bcount
#endif
#ifdef __nvapi_undef__inout_ecount_part
#undef __inout_ecount_part
#undef __nvapi_undef__inout_ecount_part
#endif
#ifdef __nvapi_undef__inout_bcount_part
#undef __inout_bcount_part
#undef __nvapi_undef__inout_bcount_part
#endif
#ifdef __nvapi_undef__inout_ecount_full
#undef __inout_ecount_full
#undef __nvapi_undef__inout_ecount_full
#endif
#ifdef __nvapi_undef__inout_bcount_full
#undef __inout_bcount_full
#undef __nvapi_undef__inout_bcount_full
#endif
#ifdef __nvapi_undef__inout_z
#undef __inout_z
#undef __nvapi_undef__inout_z
#endif
#ifdef __nvapi_undef__inout_ecount_z
#undef __inout_ecount_z
#undef __nvapi_undef__inout_ecount_z
#endif
#ifdef __nvapi_undef__inout_bcount_z
#undef __inout_bcount_z
#undef __nvapi_undef__inout_bcount_z
#endif
#ifdef __nvapi_undef__inout_nz
#undef __inout_nz
#undef __nvapi_undef__inout_nz
#endif
#ifdef __nvapi_undef__inout_ecount_nz
#undef __inout_ecount_nz
#undef __nvapi_undef__inout_ecount_nz
#endif
#ifdef __nvapi_undef__inout_bcount_nz
#undef __inout_bcount_nz
#undef __nvapi_undef__inout_bcount_nz
#endif
#ifdef __nvapi_undef__ecount_opt
#undef __ecount_opt
#undef __nvapi_undef__ecount_opt
#endif
#ifdef __nvapi_undef__bcount_opt
#undef __bcount_opt
#undef __nvapi_undef__bcount_opt
#endif
#ifdef __nvapi_undef__in_opt
#undef __in_opt
#undef __nvapi_undef__in_opt
#endif
#ifdef __nvapi_undef__in_ecount_opt
#undef __in_ecount_opt
#undef __nvapi_undef__in_ecount_opt
#endif
#ifdef __nvapi_undef__in_bcount_opt
#undef __in_bcount_opt
#undef __nvapi_undef__in_bcount_opt
#endif
#ifdef __nvapi_undef__in_z_opt
#undef __in_z_opt
#undef __nvapi_undef__in_z_opt
#endif
#ifdef __nvapi_undef__in_ecount_z_opt
#undef __in_ecount_z_opt
#undef __nvapi_undef__in_ecount_z_opt
#endif
#ifdef __nvapi_undef__in_bcount_z_opt
#undef __in_bcount_z_opt
#undef __nvapi_undef__in_bcount_z_opt
#endif
#ifdef __nvapi_undef__in_nz_opt
#undef __in_nz_opt
#undef __nvapi_undef__in_nz_opt
#endif
#ifdef __nvapi_undef__in_ecount_nz_opt
#undef __in_ecount_nz_opt
#undef __nvapi_undef__in_ecount_nz_opt
#endif
#ifdef __nvapi_undef__in_bcount_nz_opt
#undef __in_bcount_nz_opt
#undef __nvapi_undef__in_bcount_nz_opt
#endif
#ifdef __nvapi_undef__out_opt
#undef __out_opt
#undef __nvapi_undef__out_opt
#endif
#ifdef __nvapi_undef__out_ecount_opt
#undef __out_ecount_opt
#undef __nvapi_undef__out_ecount_opt
#endif
#ifdef __nvapi_undef__out_bcount_opt
#undef __out_bcount_opt
#undef __nvapi_undef__out_bcount_opt
#endif
#ifdef __nvapi_undef__out_ecount_part_opt
#undef __out_ecount_part_opt
#undef __nvapi_undef__out_ecount_part_opt
#endif
#ifdef __nvapi_undef__out_bcount_part_opt
#undef __out_bcount_part_opt
#undef __nvapi_undef__out_bcount_part_opt
#endif
#ifdef __nvapi_undef__out_ecount_full_opt
#undef __out_ecount_full_opt
#undef __nvapi_undef__out_ecount_full_opt
#endif
#ifdef __nvapi_undef__out_bcount_full_opt
#undef __out_bcount_full_opt
#undef __nvapi_undef__out_bcount_full_opt
#endif
#ifdef __nvapi_undef__out_ecount_z_opt
#undef __out_ecount_z_opt
#undef __nvapi_undef__out_ecount_z_opt
#endif
#ifdef __nvapi_undef__out_bcount_z_opt
#undef __out_bcount_z_opt
#undef __nvapi_undef__out_bcount_z_opt
#endif
#ifdef __nvapi_undef__out_ecount_part_z_opt
#undef __out_ecount_part_z_opt
#undef __nvapi_undef__out_ecount_part_z_opt
#endif
#ifdef __nvapi_undef__out_bcount_part_z_opt
#undef __out_bcount_part_z_opt
#undef __nvapi_undef__out_bcount_part_z_opt
#endif
#ifdef __nvapi_undef__out_ecount_full_z_opt
#undef __out_ecount_full_z_opt
#undef __nvapi_undef__out_ecount_full_z_opt
#endif
#ifdef __nvapi_undef__out_bcount_full_z_opt
#undef __out_bcount_full_z_opt
#undef __nvapi_undef__out_bcount_full_z_opt
#endif
#ifdef __nvapi_undef__out_ecount_nz_opt
#undef __out_ecount_nz_opt
#undef __nvapi_undef__out_ecount_nz_opt
#endif
#ifdef __nvapi_undef__out_bcount_nz_opt
#undef __out_bcount_nz_opt
#undef __nvapi_undef__out_bcount_nz_opt
#endif
#ifdef __nvapi_undef__inout_opt
#undef __inout_opt
#undef __nvapi_undef__inout_opt
#endif
#ifdef __nvapi_undef__inout_ecount_opt
#undef __inout_ecount_opt
#undef __nvapi_undef__inout_ecount_opt
#endif
#ifdef __nvapi_undef__inout_bcount_opt
#undef __inout_bcount_opt
#undef __nvapi_undef__inout_bcount_opt
#endif
#ifdef __nvapi_undef__inout_ecount_part_opt
#undef __inout_ecount_part_opt
#undef __nvapi_undef__inout_ecount_part_opt
#endif
#ifdef __nvapi_undef__inout_bcount_part_opt
#undef __inout_bcount_part_opt
#undef __nvapi_undef__inout_bcount_part_opt
#endif
#ifdef __nvapi_undef__inout_ecount_full_opt
#undef __inout_ecount_full_opt
#undef __nvapi_undef__inout_ecount_full_opt
#endif
#ifdef __nvapi_undef__inout_bcount_full_opt
#undef __inout_bcount_full_opt
#undef __nvapi_undef__inout_bcount_full_opt
#endif
#ifdef __nvapi_undef__inout_z_opt
#undef __inout_z_opt
#undef __nvapi_undef__inout_z_opt
#endif
#ifdef __nvapi_undef__inout_ecount_z_opt
#undef __inout_ecount_z_opt
#undef __nvapi_undef__inout_ecount_z_opt
#endif
#ifdef __nvapi_undef__inout_ecount_z_opt
#undef __inout_ecount_z_opt
#undef __nvapi_undef__inout_ecount_z_opt
#endif
#ifdef __nvapi_undef__inout_bcount_z_opt
#undef __inout_bcount_z_opt
#undef __nvapi_undef__inout_bcount_z_opt
#endif
#ifdef __nvapi_undef__inout_nz_opt
#undef __inout_nz_opt
#undef __nvapi_undef__inout_nz_opt
#endif
#ifdef __nvapi_undef__inout_ecount_nz_opt
#undef __inout_ecount_nz_opt
#undef __nvapi_undef__inout_ecount_nz_opt
#endif
#ifdef __nvapi_undef__inout_bcount_nz_opt
#undef __inout_bcount_nz_opt
#undef __nvapi_undef__inout_bcount_nz_opt
#endif
#ifdef __nvapi_undef__deref_ecount
#undef __deref_ecount
#undef __nvapi_undef__deref_ecount
#endif
#ifdef __nvapi_undef__deref_bcount
#undef __deref_bcount
#undef __nvapi_undef__deref_bcount
#endif
#ifdef __nvapi_undef__deref_out
#undef __deref_out
#undef __nvapi_undef__deref_out
#endif
#ifdef __nvapi_undef__deref_out_ecount
#undef __deref_out_ecount
#undef __nvapi_undef__deref_out_ecount
#endif
#ifdef __nvapi_undef__deref_out_bcount
#undef __deref_out_bcount
#undef __nvapi_undef__deref_out_bcount
#endif
#ifdef __nvapi_undef__deref_out_ecount_part
#undef __deref_out_ecount_part
#undef __nvapi_undef__deref_out_ecount_part
#endif
#ifdef __nvapi_undef__deref_out_bcount_part
#undef __deref_out_bcount_part
#undef __nvapi_undef__deref_out_bcount_part
#endif
#ifdef __nvapi_undef__deref_out_ecount_full
#undef __deref_out_ecount_full
#undef __nvapi_undef__deref_out_ecount_full
#endif
#ifdef __nvapi_undef__deref_out_bcount_full
#undef __deref_out_bcount_full
#undef __nvapi_undef__deref_out_bcount_full
#endif
#ifdef __nvapi_undef__deref_out_z
#undef __deref_out_z
#undef __nvapi_undef__deref_out_z
#endif
#ifdef __nvapi_undef__deref_out_ecount_z
#undef __deref_out_ecount_z
#undef __nvapi_undef__deref_out_ecount_z
#endif
#ifdef __nvapi_undef__deref_out_bcount_z
#undef __deref_out_bcount_z
#undef __nvapi_undef__deref_out_bcount_z
#endif
#ifdef __nvapi_undef__deref_out_nz
#undef __deref_out_nz
#undef __nvapi_undef__deref_out_nz
#endif
#ifdef __nvapi_undef__deref_out_ecount_nz
#undef __deref_out_ecount_nz
#undef __nvapi_undef__deref_out_ecount_nz
#endif
#ifdef __nvapi_undef__deref_out_bcount_nz
#undef __deref_out_bcount_nz
#undef __nvapi_undef__deref_out_bcount_nz
#endif
#ifdef __nvapi_undef__deref_inout
#undef __deref_inout
#undef __nvapi_undef__deref_inout
#endif
#ifdef __nvapi_undef__deref_inout_z
#undef __deref_inout_z
#undef __nvapi_undef__deref_inout_z
#endif
#ifdef __nvapi_undef__deref_inout_ecount
#undef __deref_inout_ecount
#undef __nvapi_undef__deref_inout_ecount
#endif
#ifdef __nvapi_undef__deref_inout_bcount
#undef __deref_inout_bcount
#undef __nvapi_undef__deref_inout_bcount
#endif
#ifdef __nvapi_undef__deref_inout_ecount_part
#undef __deref_inout_ecount_part
#undef __nvapi_undef__deref_inout_ecount_part
#endif
#ifdef __nvapi_undef__deref_inout_bcount_part
#undef __deref_inout_bcount_part
#undef __nvapi_undef__deref_inout_bcount_part
#endif
#ifdef __nvapi_undef__deref_inout_ecount_full
#undef __deref_inout_ecount_full
#undef __nvapi_undef__deref_inout_ecount_full
#endif
#ifdef __nvapi_undef__deref_inout_bcount_full
#undef __deref_inout_bcount_full
#undef __nvapi_undef__deref_inout_bcount_full
#endif
#ifdef __nvapi_undef__deref_inout_z
#undef __deref_inout_z
#undef __nvapi_undef__deref_inout_z
#endif
#ifdef __nvapi_undef__deref_inout_ecount_z
#undef __deref_inout_ecount_z
#undef __nvapi_undef__deref_inout_ecount_z
#endif
#ifdef __nvapi_undef__deref_inout_bcount_z
#undef __deref_inout_bcount_z
#undef __nvapi_undef__deref_inout_bcount_z
#endif
#ifdef __nvapi_undef__deref_inout_nz
#undef __deref_inout_nz
#undef __nvapi_undef__deref_inout_nz
#endif
#ifdef __nvapi_undef__deref_inout_ecount_nz
#undef __deref_inout_ecount_nz
#undef __nvapi_undef__deref_inout_ecount_nz
#endif
#ifdef __nvapi_undef__deref_inout_bcount_nz
#undef __deref_inout_bcount_nz
#undef __nvapi_undef__deref_inout_bcount_nz
#endif
#ifdef __nvapi_undef__deref_ecount_opt
#undef __deref_ecount_opt
#undef __nvapi_undef__deref_ecount_opt
#endif
#ifdef __nvapi_undef__deref_bcount_opt
#undef __deref_bcount_opt
#undef __nvapi_undef__deref_bcount_opt
#endif
#ifdef __nvapi_undef__deref_out_opt
#undef __deref_out_opt
#undef __nvapi_undef__deref_out_opt
#endif
#ifdef __nvapi_undef__deref_out_ecount_opt
#undef __deref_out_ecount_opt
#undef __nvapi_undef__deref_out_ecount_opt
#endif
#ifdef __nvapi_undef__deref_out_bcount_opt
#undef __deref_out_bcount_opt
#undef __nvapi_undef__deref_out_bcount_opt
#endif
#ifdef __nvapi_undef__deref_out_ecount_part_opt
#undef __deref_out_ecount_part_opt
#undef __nvapi_undef__deref_out_ecount_part_opt
#endif
#ifdef __nvapi_undef__deref_out_bcount_part_opt
#undef __deref_out_bcount_part_opt
#undef __nvapi_undef__deref_out_bcount_part_opt
#endif
#ifdef __nvapi_undef__deref_out_ecount_full_opt
#undef __deref_out_ecount_full_opt
#undef __nvapi_undef__deref_out_ecount_full_opt
#endif
#ifdef __nvapi_undef__deref_out_bcount_full_opt
#undef __deref_out_bcount_full_opt
#undef __nvapi_undef__deref_out_bcount_full_opt
#endif
#ifdef __nvapi_undef__deref_out_z_opt
#undef __deref_out_z_opt
#undef __nvapi_undef__deref_out_z_opt
#endif
#ifdef __nvapi_undef__deref_out_ecount_z_opt
#undef __deref_out_ecount_z_opt
#undef __nvapi_undef__deref_out_ecount_z_opt
#endif
#ifdef __nvapi_undef__deref_out_bcount_z_opt
#undef __deref_out_bcount_z_opt
#undef __nvapi_undef__deref_out_bcount_z_opt
#endif
#ifdef __nvapi_undef__deref_out_nz_opt
#undef __deref_out_nz_opt
#undef __nvapi_undef__deref_out_nz_opt
#endif
#ifdef __nvapi_undef__deref_out_ecount_nz_opt
#undef __deref_out_ecount_nz_opt
#undef __nvapi_undef__deref_out_ecount_nz_opt
#endif
#ifdef __nvapi_undef__deref_out_bcount_nz_opt
#undef __deref_out_bcount_nz_opt
#undef __nvapi_undef__deref_out_bcount_nz_opt
#endif
#ifdef __nvapi_undef__deref_inout_opt
#undef __deref_inout_opt
#undef __nvapi_undef__deref_inout_opt
#endif
#ifdef __nvapi_undef__deref_inout_ecount_opt
#undef __deref_inout_ecount_opt
#undef __nvapi_undef__deref_inout_ecount_opt
#endif
#ifdef __nvapi_undef__deref_inout_bcount_opt
#undef __deref_inout_bcount_opt
#undef __nvapi_undef__deref_inout_bcount_opt
#endif
#ifdef __nvapi_undef__deref_inout_ecount_part_opt
#undef __deref_inout_ecount_part_opt
#undef __nvapi_undef__deref_inout_ecount_part_opt
#endif
#ifdef __nvapi_undef__deref_inout_bcount_part_opt
#undef __deref_inout_bcount_part_opt
#undef __nvapi_undef__deref_inout_bcount_part_opt
#endif
#ifdef __nvapi_undef__deref_inout_ecount_full_opt
#undef __deref_inout_ecount_full_opt
#undef __nvapi_undef__deref_inout_ecount_full_opt
#endif
#ifdef __nvapi_undef__deref_inout_bcount_full_opt
#undef __deref_inout_bcount_full_opt
#undef __nvapi_undef__deref_inout_bcount_full_opt
#endif
#ifdef __nvapi_undef__deref_inout_z_opt
#undef __deref_inout_z_opt
#undef __nvapi_undef__deref_inout_z_opt
#endif
#ifdef __nvapi_undef__deref_inout_ecount_z_opt
#undef __deref_inout_ecount_z_opt
#undef __nvapi_undef__deref_inout_ecount_z_opt
#endif
#ifdef __nvapi_undef__deref_inout_bcount_z_opt
#undef __deref_inout_bcount_z_opt
#undef __nvapi_undef__deref_inout_bcount_z_opt
#endif
#ifdef __nvapi_undef__deref_inout_nz_opt
#undef __deref_inout_nz_opt
#undef __nvapi_undef__deref_inout_nz_opt
#endif
#ifdef __nvapi_undef__deref_inout_ecount_nz_opt
#undef __deref_inout_ecount_nz_opt
#undef __nvapi_undef__deref_inout_ecount_nz_opt
#endif
#ifdef __nvapi_undef__deref_inout_bcount_nz_opt
#undef __deref_inout_bcount_nz_opt
#undef __nvapi_undef__deref_inout_bcount_nz_opt
#endif
#ifdef __nvapi_undef__deref_opt_ecount
#undef __deref_opt_ecount
#undef __nvapi_undef__deref_opt_ecount
#endif
#ifdef __nvapi_undef__deref_opt_bcount
#undef __deref_opt_bcount
#undef __nvapi_undef__deref_opt_bcount
#endif
#ifdef __nvapi_undef__deref_opt_out
#undef __deref_opt_out
#undef __nvapi_undef__deref_opt_out
#endif
#ifdef __nvapi_undef__deref_opt_out_z
#undef __deref_opt_out_z
#undef __nvapi_undef__deref_opt_out_z
#endif
#ifdef __nvapi_undef__deref_opt_out_ecount
#undef __deref_opt_out_ecount
#undef __nvapi_undef__deref_opt_out_ecount
#endif
#ifdef __nvapi_undef__deref_opt_out_bcount
#undef __deref_opt_out_bcount
#undef __nvapi_undef__deref_opt_out_bcount
#endif
#ifdef __nvapi_undef__deref_opt_out_ecount_part
#undef __deref_opt_out_ecount_part
#undef __nvapi_undef__deref_opt_out_ecount_part
#endif
#ifdef __nvapi_undef__deref_opt_out_bcount_part
#undef __deref_opt_out_bcount_part
#undef __nvapi_undef__deref_opt_out_bcount_part
#endif
#ifdef __nvapi_undef__deref_opt_out_ecount_full
#undef __deref_opt_out_ecount_full
#undef __nvapi_undef__deref_opt_out_ecount_full
#endif
#ifdef __nvapi_undef__deref_opt_out_bcount_full
#undef __deref_opt_out_bcount_full
#undef __nvapi_undef__deref_opt_out_bcount_full
#endif
#ifdef __nvapi_undef__deref_opt_inout
#undef __deref_opt_inout
#undef __nvapi_undef__deref_opt_inout
#endif
#ifdef __nvapi_undef__deref_opt_inout_ecount
#undef __deref_opt_inout_ecount
#undef __nvapi_undef__deref_opt_inout_ecount
#endif
#ifdef __nvapi_undef__deref_opt_inout_bcount
#undef __deref_opt_inout_bcount
#undef __nvapi_undef__deref_opt_inout_bcount
#endif
#ifdef __nvapi_undef__deref_opt_inout_ecount_part
#undef __deref_opt_inout_ecount_part
#undef __nvapi_undef__deref_opt_inout_ecount_part
#endif
#ifdef __nvapi_undef__deref_opt_inout_bcount_part
#undef __deref_opt_inout_bcount_part
#undef __nvapi_undef__deref_opt_inout_bcount_part
#endif
#ifdef __nvapi_undef__deref_opt_inout_ecount_full
#undef __deref_opt_inout_ecount_full
#undef __nvapi_undef__deref_opt_inout_ecount_full
#endif
#ifdef __nvapi_undef__deref_opt_inout_bcount_full
#undef __deref_opt_inout_bcount_full
#undef __nvapi_undef__deref_opt_inout_bcount_full
#endif
#ifdef __nvapi_undef__deref_opt_inout_z
#undef __deref_opt_inout_z
#undef __nvapi_undef__deref_opt_inout_z
#endif
#ifdef __nvapi_undef__deref_opt_inout_ecount_z
#undef __deref_opt_inout_ecount_z
#undef __nvapi_undef__deref_opt_inout_ecount_z
#endif
#ifdef __nvapi_undef__deref_opt_inout_bcount_z
#undef __deref_opt_inout_bcount_z
#undef __nvapi_undef__deref_opt_inout_bcount_z
#endif
#ifdef __nvapi_undef__deref_opt_inout_nz
#undef __deref_opt_inout_nz
#undef __nvapi_undef__deref_opt_inout_nz
#endif
#ifdef __nvapi_undef__deref_opt_inout_ecount_nz
#undef __deref_opt_inout_ecount_nz
#undef __nvapi_undef__deref_opt_inout_ecount_nz
#endif
#ifdef __nvapi_undef__deref_opt_inout_bcount_nz
#undef __deref_opt_inout_bcount_nz
#undef __nvapi_undef__deref_opt_inout_bcount_nz
#endif
#ifdef __nvapi_undef__deref_opt_ecount_opt
#undef __deref_opt_ecount_opt
#undef __nvapi_undef__deref_opt_ecount_opt
#endif
#ifdef __nvapi_undef__deref_opt_bcount_opt
#undef __deref_opt_bcount_opt
#undef __nvapi_undef__deref_opt_bcount_opt
#endif
#ifdef __nvapi_undef__deref_opt_out_opt
#undef __deref_opt_out_opt
#undef __nvapi_undef__deref_opt_out_opt
#endif
#ifdef __nvapi_undef__deref_opt_out_ecount_opt
#undef __deref_opt_out_ecount_opt
#undef __nvapi_undef__deref_opt_out_ecount_opt
#endif
#ifdef __nvapi_undef__deref_opt_out_bcount_opt
#undef __deref_opt_out_bcount_opt
#undef __nvapi_undef__deref_opt_out_bcount_opt
#endif
#ifdef __nvapi_undef__deref_opt_out_ecount_part_opt
#undef __deref_opt_out_ecount_part_opt
#undef __nvapi_undef__deref_opt_out_ecount_part_opt
#endif
#ifdef __nvapi_undef__deref_opt_out_bcount_part_opt
#undef __deref_opt_out_bcount_part_opt
#undef __nvapi_undef__deref_opt_out_bcount_part_opt
#endif
#ifdef __nvapi_undef__deref_opt_out_ecount_full_opt
#undef __deref_opt_out_ecount_full_opt
#undef __nvapi_undef__deref_opt_out_ecount_full_opt
#endif
#ifdef __nvapi_undef__deref_opt_out_bcount_full_opt
#undef __deref_opt_out_bcount_full_opt
#undef __nvapi_undef__deref_opt_out_bcount_full_opt
#endif
#ifdef __nvapi_undef__deref_opt_out_z_opt
#undef __deref_opt_out_z_opt
#undef __nvapi_undef__deref_opt_out_z_opt
#endif
#ifdef __nvapi_undef__deref_opt_out_ecount_z_opt
#undef __deref_opt_out_ecount_z_opt
#undef __nvapi_undef__deref_opt_out_ecount_z_opt
#endif
#ifdef __nvapi_undef__deref_opt_out_bcount_z_opt
#undef __deref_opt_out_bcount_z_opt
#undef __nvapi_undef__deref_opt_out_bcount_z_opt
#endif
#ifdef __nvapi_undef__deref_opt_out_nz_opt
#undef __deref_opt_out_nz_opt
#undef __nvapi_undef__deref_opt_out_nz_opt
#endif
#ifdef __nvapi_undef__deref_opt_out_ecount_nz_opt
#undef __deref_opt_out_ecount_nz_opt
#undef __nvapi_undef__deref_opt_out_ecount_nz_opt
#endif
#ifdef __nvapi_undef__deref_opt_out_bcount_nz_opt
#undef __deref_opt_out_bcount_nz_opt
#undef __nvapi_undef__deref_opt_out_bcount_nz_opt
#endif
#ifdef __nvapi_undef__deref_opt_inout_opt
#undef __deref_opt_inout_opt
#undef __nvapi_undef__deref_opt_inout_opt
#endif
#ifdef __nvapi_undef__deref_opt_inout_ecount_opt
#undef __deref_opt_inout_ecount_opt
#undef __nvapi_undef__deref_opt_inout_ecount_opt
#endif
#ifdef __nvapi_undef__deref_opt_inout_bcount_opt
#undef __deref_opt_inout_bcount_opt
#undef __nvapi_undef__deref_opt_inout_bcount_opt
#endif
#ifdef __nvapi_undef__deref_opt_inout_ecount_part_opt
#undef __deref_opt_inout_ecount_part_opt
#undef __nvapi_undef__deref_opt_inout_ecount_part_opt
#endif
#ifdef __nvapi_undef__deref_opt_inout_bcount_part_opt
#undef __deref_opt_inout_bcount_part_opt
#undef __nvapi_undef__deref_opt_inout_bcount_part_opt
#endif
#ifdef __nvapi_undef__deref_opt_inout_ecount_full_opt
#undef __deref_opt_inout_ecount_full_opt
#undef __nvapi_undef__deref_opt_inout_ecount_full_opt
#endif
#ifdef __nvapi_undef__deref_opt_inout_bcount_full_opt
#undef __deref_opt_inout_bcount_full_opt
#undef __nvapi_undef__deref_opt_inout_bcount_full_opt
#endif
#ifdef __nvapi_undef__deref_opt_inout_z_opt
#undef __deref_opt_inout_z_opt
#undef __nvapi_undef__deref_opt_inout_z_opt
#endif
#ifdef __nvapi_undef__deref_opt_inout_ecount_z_opt
#undef __deref_opt_inout_ecount_z_opt
#undef __nvapi_undef__deref_opt_inout_ecount_z_opt
#endif
#ifdef __nvapi_undef__deref_opt_inout_bcount_z_opt
#undef __deref_opt_inout_bcount_z_opt
#undef __nvapi_undef__deref_opt_inout_bcount_z_opt
#endif
#ifdef __nvapi_undef__deref_opt_inout_nz_opt
#undef __deref_opt_inout_nz_opt
#undef __nvapi_undef__deref_opt_inout_nz_opt
#endif
#ifdef __nvapi_undef__deref_opt_inout_ecount_nz_opt
#undef __deref_opt_inout_ecount_nz_opt
#undef __nvapi_undef__deref_opt_inout_ecount_nz_opt
#endif
#ifdef __nvapi_undef__deref_opt_inout_bcount_nz_opt
#undef __deref_opt_inout_bcount_nz_opt
#undef __nvapi_undef__deref_opt_inout_bcount_nz_opt
#endif
#ifdef __nvapi_success
#undef __success
#undef __nvapi_success
#endif
#ifdef __nvapi__Ret_notnull_
#undef __nvapi__Ret_notnull_
#undef _Ret_notnull_
#endif
#ifdef __nvapi__Post_writable_byte_size_
#undef __nvapi__Post_writable_byte_size_
#undef _Post_writable_byte_size_
#endif
#ifdef __nvapi_Outptr_
#undef __nvapi_Outptr_
#undef _Outptr_
#endif
#endif // __NVAPI_EMPTY_SAL

View File

@@ -0,0 +1,812 @@
/*********************************************************************************************************\
|* *|
|* SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. *|
|* SPDX-License-Identifier: MIT *|
|* *|
|* 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. *|
|* *|
|* *|
\*********************************************************************************************************/
// ====================================================
// SAL related support
// ====================================================
#ifndef __ecount
#define __nvapi_undef__ecount
#define __ecount(size)
#endif
#ifndef __bcount
#define __nvapi_undef__bcount
#define __bcount(size)
#endif
#ifndef __in
#define __nvapi_undef__in
#define __in
#endif
#ifndef __in_ecount
#define __nvapi_undef__in_ecount
#define __in_ecount(size)
#endif
#ifndef __in_bcount
#define __nvapi_undef__in_bcount
#define __in_bcount(size)
#endif
#ifndef __in_z
#define __nvapi_undef__in_z
#define __in_z
#endif
#ifndef __in_ecount_z
#define __nvapi_undef__in_ecount_z
#define __in_ecount_z(size)
#endif
#ifndef __in_bcount_z
#define __nvapi_undef__in_bcount_z
#define __in_bcount_z(size)
#endif
#ifndef __in_nz
#define __nvapi_undef__in_nz
#define __in_nz
#endif
#ifndef __in_ecount_nz
#define __nvapi_undef__in_ecount_nz
#define __in_ecount_nz(size)
#endif
#ifndef __in_bcount_nz
#define __nvapi_undef__in_bcount_nz
#define __in_bcount_nz(size)
#endif
#ifndef __out
#define __nvapi_undef__out
#define __out
#endif
#ifndef __out_ecount
#define __nvapi_undef__out_ecount
#define __out_ecount(size)
#endif
#ifndef __out_bcount
#define __nvapi_undef__out_bcount
#define __out_bcount(size)
#endif
#ifndef __out_ecount_part
#define __nvapi_undef__out_ecount_part
#define __out_ecount_part(size,length)
#endif
#ifndef __out_bcount_part
#define __nvapi_undef__out_bcount_part
#define __out_bcount_part(size,length)
#endif
#ifndef __out_ecount_full
#define __nvapi_undef__out_ecount_full
#define __out_ecount_full(size)
#endif
#ifndef __out_bcount_full
#define __nvapi_undef__out_bcount_full
#define __out_bcount_full(size)
#endif
#ifndef __out_z
#define __nvapi_undef__out_z
#define __out_z
#endif
#ifndef __out_z_opt
#define __nvapi_undef__out_z_opt
#define __out_z_opt
#endif
#ifndef __out_ecount_z
#define __nvapi_undef__out_ecount_z
#define __out_ecount_z(size)
#endif
#ifndef __out_bcount_z
#define __nvapi_undef__out_bcount_z
#define __out_bcount_z(size)
#endif
#ifndef __out_ecount_part_z
#define __nvapi_undef__out_ecount_part_z
#define __out_ecount_part_z(size,length)
#endif
#ifndef __out_bcount_part_z
#define __nvapi_undef__out_bcount_part_z
#define __out_bcount_part_z(size,length)
#endif
#ifndef __out_ecount_full_z
#define __nvapi_undef__out_ecount_full_z
#define __out_ecount_full_z(size)
#endif
#ifndef __out_bcount_full_z
#define __nvapi_undef__out_bcount_full_z
#define __out_bcount_full_z(size)
#endif
#ifndef __out_nz
#define __nvapi_undef__out_nz
#define __out_nz
#endif
#ifndef __out_nz_opt
#define __nvapi_undef__out_nz_opt
#define __out_nz_opt
#endif
#ifndef __out_ecount_nz
#define __nvapi_undef__out_ecount_nz
#define __out_ecount_nz(size)
#endif
#ifndef __out_bcount_nz
#define __nvapi_undef__out_bcount_nz
#define __out_bcount_nz(size)
#endif
#ifndef __inout
#define __nvapi_undef__inout
#define __inout
#endif
#ifndef __inout_ecount
#define __nvapi_undef__inout_ecount
#define __inout_ecount(size)
#endif
#ifndef __inout_bcount
#define __nvapi_undef__inout_bcount
#define __inout_bcount(size)
#endif
#ifndef __inout_ecount_part
#define __nvapi_undef__inout_ecount_part
#define __inout_ecount_part(size,length)
#endif
#ifndef __inout_bcount_part
#define __nvapi_undef__inout_bcount_part
#define __inout_bcount_part(size,length)
#endif
#ifndef __inout_ecount_full
#define __nvapi_undef__inout_ecount_full
#define __inout_ecount_full(size)
#endif
#ifndef __inout_bcount_full
#define __nvapi_undef__inout_bcount_full
#define __inout_bcount_full(size)
#endif
#ifndef __inout_z
#define __nvapi_undef__inout_z
#define __inout_z
#endif
#ifndef __inout_ecount_z
#define __nvapi_undef__inout_ecount_z
#define __inout_ecount_z(size)
#endif
#ifndef __inout_bcount_z
#define __nvapi_undef__inout_bcount_z
#define __inout_bcount_z(size)
#endif
#ifndef __inout_nz
#define __nvapi_undef__inout_nz
#define __inout_nz
#endif
#ifndef __inout_ecount_nz
#define __nvapi_undef__inout_ecount_nz
#define __inout_ecount_nz(size)
#endif
#ifndef __inout_bcount_nz
#define __nvapi_undef__inout_bcount_nz
#define __inout_bcount_nz(size)
#endif
#ifndef __ecount_opt
#define __nvapi_undef__ecount_opt
#define __ecount_opt(size)
#endif
#ifndef __bcount_opt
#define __nvapi_undef__bcount_opt
#define __bcount_opt(size)
#endif
#ifndef __in_opt
#define __nvapi_undef__in_opt
#define __in_opt
#endif
#ifndef __in_ecount_opt
#define __nvapi_undef__in_ecount_opt
#define __in_ecount_opt(size)
#endif
#ifndef __in_bcount_opt
#define __nvapi_undef__in_bcount_opt
#define __in_bcount_opt(size)
#endif
#ifndef __in_z_opt
#define __nvapi_undef__in_z_opt
#define __in_z_opt
#endif
#ifndef __in_ecount_z_opt
#define __nvapi_undef__in_ecount_z_opt
#define __in_ecount_z_opt(size)
#endif
#ifndef __in_bcount_z_opt
#define __nvapi_undef__in_bcount_z_opt
#define __in_bcount_z_opt(size)
#endif
#ifndef __in_nz_opt
#define __nvapi_undef__in_nz_opt
#define __in_nz_opt
#endif
#ifndef __in_ecount_nz_opt
#define __nvapi_undef__in_ecount_nz_opt
#define __in_ecount_nz_opt(size)
#endif
#ifndef __in_bcount_nz_opt
#define __nvapi_undef__in_bcount_nz_opt
#define __in_bcount_nz_opt(size)
#endif
#ifndef __out_opt
#define __nvapi_undef__out_opt
#define __out_opt
#endif
#ifndef __out_ecount_opt
#define __nvapi_undef__out_ecount_opt
#define __out_ecount_opt(size)
#endif
#ifndef __out_bcount_opt
#define __nvapi_undef__out_bcount_opt
#define __out_bcount_opt(size)
#endif
#ifndef __out_ecount_part_opt
#define __nvapi_undef__out_ecount_part_opt
#define __out_ecount_part_opt(size,length)
#endif
#ifndef __out_bcount_part_opt
#define __nvapi_undef__out_bcount_part_opt
#define __out_bcount_part_opt(size,length)
#endif
#ifndef __out_ecount_full_opt
#define __nvapi_undef__out_ecount_full_opt
#define __out_ecount_full_opt(size)
#endif
#ifndef __out_bcount_full_opt
#define __nvapi_undef__out_bcount_full_opt
#define __out_bcount_full_opt(size)
#endif
#ifndef __out_ecount_z_opt
#define __nvapi_undef__out_ecount_z_opt
#define __out_ecount_z_opt(size)
#endif
#ifndef __out_bcount_z_opt
#define __nvapi_undef__out_bcount_z_opt
#define __out_bcount_z_opt(size)
#endif
#ifndef __out_ecount_part_z_opt
#define __nvapi_undef__out_ecount_part_z_opt
#define __out_ecount_part_z_opt(size,length)
#endif
#ifndef __out_bcount_part_z_opt
#define __nvapi_undef__out_bcount_part_z_opt
#define __out_bcount_part_z_opt(size,length)
#endif
#ifndef __out_ecount_full_z_opt
#define __nvapi_undef__out_ecount_full_z_opt
#define __out_ecount_full_z_opt(size)
#endif
#ifndef __out_bcount_full_z_opt
#define __nvapi_undef__out_bcount_full_z_opt
#define __out_bcount_full_z_opt(size)
#endif
#ifndef __out_ecount_nz_opt
#define __nvapi_undef__out_ecount_nz_opt
#define __out_ecount_nz_opt(size)
#endif
#ifndef __out_bcount_nz_opt
#define __nvapi_undef__out_bcount_nz_opt
#define __out_bcount_nz_opt(size)
#endif
#ifndef __inout_opt
#define __nvapi_undef__inout_opt
#define __inout_opt
#endif
#ifndef __inout_ecount_opt
#define __nvapi_undef__inout_ecount_opt
#define __inout_ecount_opt(size)
#endif
#ifndef __inout_bcount_opt
#define __nvapi_undef__inout_bcount_opt
#define __inout_bcount_opt(size)
#endif
#ifndef __inout_ecount_part_opt
#define __nvapi_undef__inout_ecount_part_opt
#define __inout_ecount_part_opt(size,length)
#endif
#ifndef __inout_bcount_part_opt
#define __nvapi_undef__inout_bcount_part_opt
#define __inout_bcount_part_opt(size,length)
#endif
#ifndef __inout_ecount_full_opt
#define __nvapi_undef__inout_ecount_full_opt
#define __inout_ecount_full_opt(size)
#endif
#ifndef __inout_bcount_full_opt
#define __nvapi_undef__inout_bcount_full_opt
#define __inout_bcount_full_opt(size)
#endif
#ifndef __inout_z_opt
#define __nvapi_undef__inout_z_opt
#define __inout_z_opt
#endif
#ifndef __inout_ecount_z_opt
#define __nvapi_undef__inout_ecount_z_opt
#define __inout_ecount_z_opt(size)
#endif
#ifndef __inout_ecount_z_opt
#define __nvapi_undef__inout_ecount_z_opt
#define __inout_ecount_z_opt(size)
#endif
#ifndef __inout_bcount_z_opt
#define __nvapi_undef__inout_bcount_z_opt
#define __inout_bcount_z_opt(size)
#endif
#ifndef __inout_nz_opt
#define __nvapi_undef__inout_nz_opt
#define __inout_nz_opt
#endif
#ifndef __inout_ecount_nz_opt
#define __nvapi_undef__inout_ecount_nz_opt
#define __inout_ecount_nz_opt(size)
#endif
#ifndef __inout_bcount_nz_opt
#define __nvapi_undef__inout_bcount_nz_opt
#define __inout_bcount_nz_opt(size)
#endif
#ifndef __deref_ecount
#define __nvapi_undef__deref_ecount
#define __deref_ecount(size)
#endif
#ifndef __deref_bcount
#define __nvapi_undef__deref_bcount
#define __deref_bcount(size)
#endif
#ifndef __deref_out
#define __nvapi_undef__deref_out
#define __deref_out
#endif
#ifndef __deref_out_ecount
#define __nvapi_undef__deref_out_ecount
#define __deref_out_ecount(size)
#endif
#ifndef __deref_out_bcount
#define __nvapi_undef__deref_out_bcount
#define __deref_out_bcount(size)
#endif
#ifndef __deref_out_ecount_part
#define __nvapi_undef__deref_out_ecount_part
#define __deref_out_ecount_part(size,length)
#endif
#ifndef __deref_out_bcount_part
#define __nvapi_undef__deref_out_bcount_part
#define __deref_out_bcount_part(size,length)
#endif
#ifndef __deref_out_ecount_full
#define __nvapi_undef__deref_out_ecount_full
#define __deref_out_ecount_full(size)
#endif
#ifndef __deref_out_bcount_full
#define __nvapi_undef__deref_out_bcount_full
#define __deref_out_bcount_full(size)
#endif
#ifndef __deref_out_z
#define __nvapi_undef__deref_out_z
#define __deref_out_z
#endif
#ifndef __deref_out_ecount_z
#define __nvapi_undef__deref_out_ecount_z
#define __deref_out_ecount_z(size)
#endif
#ifndef __deref_out_bcount_z
#define __nvapi_undef__deref_out_bcount_z
#define __deref_out_bcount_z(size)
#endif
#ifndef __deref_out_nz
#define __nvapi_undef__deref_out_nz
#define __deref_out_nz
#endif
#ifndef __deref_out_ecount_nz
#define __nvapi_undef__deref_out_ecount_nz
#define __deref_out_ecount_nz(size)
#endif
#ifndef __deref_out_bcount_nz
#define __nvapi_undef__deref_out_bcount_nz
#define __deref_out_bcount_nz(size)
#endif
#ifndef __deref_inout
#define __nvapi_undef__deref_inout
#define __deref_inout
#endif
#ifndef __deref_inout_z
#define __nvapi_undef__deref_inout_z
#define __deref_inout_z
#endif
#ifndef __deref_inout_ecount
#define __nvapi_undef__deref_inout_ecount
#define __deref_inout_ecount(size)
#endif
#ifndef __deref_inout_bcount
#define __nvapi_undef__deref_inout_bcount
#define __deref_inout_bcount(size)
#endif
#ifndef __deref_inout_ecount_part
#define __nvapi_undef__deref_inout_ecount_part
#define __deref_inout_ecount_part(size,length)
#endif
#ifndef __deref_inout_bcount_part
#define __nvapi_undef__deref_inout_bcount_part
#define __deref_inout_bcount_part(size,length)
#endif
#ifndef __deref_inout_ecount_full
#define __nvapi_undef__deref_inout_ecount_full
#define __deref_inout_ecount_full(size)
#endif
#ifndef __deref_inout_bcount_full
#define __nvapi_undef__deref_inout_bcount_full
#define __deref_inout_bcount_full(size)
#endif
#ifndef __deref_inout_z
#define __nvapi_undef__deref_inout_z
#define __deref_inout_z
#endif
#ifndef __deref_inout_ecount_z
#define __nvapi_undef__deref_inout_ecount_z
#define __deref_inout_ecount_z(size)
#endif
#ifndef __deref_inout_bcount_z
#define __nvapi_undef__deref_inout_bcount_z
#define __deref_inout_bcount_z(size)
#endif
#ifndef __deref_inout_nz
#define __nvapi_undef__deref_inout_nz
#define __deref_inout_nz
#endif
#ifndef __deref_inout_ecount_nz
#define __nvapi_undef__deref_inout_ecount_nz
#define __deref_inout_ecount_nz(size)
#endif
#ifndef __deref_inout_bcount_nz
#define __nvapi_undef__deref_inout_bcount_nz
#define __deref_inout_bcount_nz(size)
#endif
#ifndef __deref_ecount_opt
#define __nvapi_undef__deref_ecount_opt
#define __deref_ecount_opt(size)
#endif
#ifndef __deref_bcount_opt
#define __nvapi_undef__deref_bcount_opt
#define __deref_bcount_opt(size)
#endif
#ifndef __deref_out_opt
#define __nvapi_undef__deref_out_opt
#define __deref_out_opt
#endif
#ifndef __deref_out_ecount_opt
#define __nvapi_undef__deref_out_ecount_opt
#define __deref_out_ecount_opt(size)
#endif
#ifndef __deref_out_bcount_opt
#define __nvapi_undef__deref_out_bcount_opt
#define __deref_out_bcount_opt(size)
#endif
#ifndef __deref_out_ecount_part_opt
#define __nvapi_undef__deref_out_ecount_part_opt
#define __deref_out_ecount_part_opt(size,length)
#endif
#ifndef __deref_out_bcount_part_opt
#define __nvapi_undef__deref_out_bcount_part_opt
#define __deref_out_bcount_part_opt(size,length)
#endif
#ifndef __deref_out_ecount_full_opt
#define __nvapi_undef__deref_out_ecount_full_opt
#define __deref_out_ecount_full_opt(size)
#endif
#ifndef __deref_out_bcount_full_opt
#define __nvapi_undef__deref_out_bcount_full_opt
#define __deref_out_bcount_full_opt(size)
#endif
#ifndef __deref_out_z_opt
#define __nvapi_undef__deref_out_z_opt
#define __deref_out_z_opt
#endif
#ifndef __deref_out_ecount_z_opt
#define __nvapi_undef__deref_out_ecount_z_opt
#define __deref_out_ecount_z_opt(size)
#endif
#ifndef __deref_out_bcount_z_opt
#define __nvapi_undef__deref_out_bcount_z_opt
#define __deref_out_bcount_z_opt(size)
#endif
#ifndef __deref_out_nz_opt
#define __nvapi_undef__deref_out_nz_opt
#define __deref_out_nz_opt
#endif
#ifndef __deref_out_ecount_nz_opt
#define __nvapi_undef__deref_out_ecount_nz_opt
#define __deref_out_ecount_nz_opt(size)
#endif
#ifndef __deref_out_bcount_nz_opt
#define __nvapi_undef__deref_out_bcount_nz_opt
#define __deref_out_bcount_nz_opt(size)
#endif
#ifndef __deref_inout_opt
#define __nvapi_undef__deref_inout_opt
#define __deref_inout_opt
#endif
#ifndef __deref_inout_ecount_opt
#define __nvapi_undef__deref_inout_ecount_opt
#define __deref_inout_ecount_opt(size)
#endif
#ifndef __deref_inout_bcount_opt
#define __nvapi_undef__deref_inout_bcount_opt
#define __deref_inout_bcount_opt(size)
#endif
#ifndef __deref_inout_ecount_part_opt
#define __nvapi_undef__deref_inout_ecount_part_opt
#define __deref_inout_ecount_part_opt(size,length)
#endif
#ifndef __deref_inout_bcount_part_opt
#define __nvapi_undef__deref_inout_bcount_part_opt
#define __deref_inout_bcount_part_opt(size,length)
#endif
#ifndef __deref_inout_ecount_full_opt
#define __nvapi_undef__deref_inout_ecount_full_opt
#define __deref_inout_ecount_full_opt(size)
#endif
#ifndef __deref_inout_bcount_full_opt
#define __nvapi_undef__deref_inout_bcount_full_opt
#define __deref_inout_bcount_full_opt(size)
#endif
#ifndef __deref_inout_z_opt
#define __nvapi_undef__deref_inout_z_opt
#define __deref_inout_z_opt
#endif
#ifndef __deref_inout_ecount_z_opt
#define __nvapi_undef__deref_inout_ecount_z_opt
#define __deref_inout_ecount_z_opt(size)
#endif
#ifndef __deref_inout_bcount_z_opt
#define __nvapi_undef__deref_inout_bcount_z_opt
#define __deref_inout_bcount_z_opt(size)
#endif
#ifndef __deref_inout_nz_opt
#define __nvapi_undef__deref_inout_nz_opt
#define __deref_inout_nz_opt
#endif
#ifndef __deref_inout_ecount_nz_opt
#define __nvapi_undef__deref_inout_ecount_nz_opt
#define __deref_inout_ecount_nz_opt(size)
#endif
#ifndef __deref_inout_bcount_nz_opt
#define __nvapi_undef__deref_inout_bcount_nz_opt
#define __deref_inout_bcount_nz_opt(size)
#endif
#ifndef __deref_opt_ecount
#define __nvapi_undef__deref_opt_ecount
#define __deref_opt_ecount(size)
#endif
#ifndef __deref_opt_bcount
#define __nvapi_undef__deref_opt_bcount
#define __deref_opt_bcount(size)
#endif
#ifndef __deref_opt_out
#define __nvapi_undef__deref_opt_out
#define __deref_opt_out
#endif
#ifndef __deref_opt_out_z
#define __nvapi_undef__deref_opt_out_z
#define __deref_opt_out_z
#endif
#ifndef __deref_opt_out_ecount
#define __nvapi_undef__deref_opt_out_ecount
#define __deref_opt_out_ecount(size)
#endif
#ifndef __deref_opt_out_bcount
#define __nvapi_undef__deref_opt_out_bcount
#define __deref_opt_out_bcount(size)
#endif
#ifndef __deref_opt_out_ecount_part
#define __nvapi_undef__deref_opt_out_ecount_part
#define __deref_opt_out_ecount_part(size,length)
#endif
#ifndef __deref_opt_out_bcount_part
#define __nvapi_undef__deref_opt_out_bcount_part
#define __deref_opt_out_bcount_part(size,length)
#endif
#ifndef __deref_opt_out_ecount_full
#define __nvapi_undef__deref_opt_out_ecount_full
#define __deref_opt_out_ecount_full(size)
#endif
#ifndef __deref_opt_out_bcount_full
#define __nvapi_undef__deref_opt_out_bcount_full
#define __deref_opt_out_bcount_full(size)
#endif
#ifndef __deref_opt_inout
#define __nvapi_undef__deref_opt_inout
#define __deref_opt_inout
#endif
#ifndef __deref_opt_inout_ecount
#define __nvapi_undef__deref_opt_inout_ecount
#define __deref_opt_inout_ecount(size)
#endif
#ifndef __deref_opt_inout_bcount
#define __nvapi_undef__deref_opt_inout_bcount
#define __deref_opt_inout_bcount(size)
#endif
#ifndef __deref_opt_inout_ecount_part
#define __nvapi_undef__deref_opt_inout_ecount_part
#define __deref_opt_inout_ecount_part(size,length)
#endif
#ifndef __deref_opt_inout_bcount_part
#define __nvapi_undef__deref_opt_inout_bcount_part
#define __deref_opt_inout_bcount_part(size,length)
#endif
#ifndef __deref_opt_inout_ecount_full
#define __nvapi_undef__deref_opt_inout_ecount_full
#define __deref_opt_inout_ecount_full(size)
#endif
#ifndef __deref_opt_inout_bcount_full
#define __nvapi_undef__deref_opt_inout_bcount_full
#define __deref_opt_inout_bcount_full(size)
#endif
#ifndef __deref_opt_inout_z
#define __nvapi_undef__deref_opt_inout_z
#define __deref_opt_inout_z
#endif
#ifndef __deref_opt_inout_ecount_z
#define __nvapi_undef__deref_opt_inout_ecount_z
#define __deref_opt_inout_ecount_z(size)
#endif
#ifndef __deref_opt_inout_bcount_z
#define __nvapi_undef__deref_opt_inout_bcount_z
#define __deref_opt_inout_bcount_z(size)
#endif
#ifndef __deref_opt_inout_nz
#define __nvapi_undef__deref_opt_inout_nz
#define __deref_opt_inout_nz
#endif
#ifndef __deref_opt_inout_ecount_nz
#define __nvapi_undef__deref_opt_inout_ecount_nz
#define __deref_opt_inout_ecount_nz(size)
#endif
#ifndef __deref_opt_inout_bcount_nz
#define __nvapi_undef__deref_opt_inout_bcount_nz
#define __deref_opt_inout_bcount_nz(size)
#endif
#ifndef __deref_opt_ecount_opt
#define __nvapi_undef__deref_opt_ecount_opt
#define __deref_opt_ecount_opt(size)
#endif
#ifndef __deref_opt_bcount_opt
#define __nvapi_undef__deref_opt_bcount_opt
#define __deref_opt_bcount_opt(size)
#endif
#ifndef __deref_opt_out_opt
#define __nvapi_undef__deref_opt_out_opt
#define __deref_opt_out_opt
#endif
#ifndef __deref_opt_out_ecount_opt
#define __nvapi_undef__deref_opt_out_ecount_opt
#define __deref_opt_out_ecount_opt(size)
#endif
#ifndef __deref_opt_out_bcount_opt
#define __nvapi_undef__deref_opt_out_bcount_opt
#define __deref_opt_out_bcount_opt(size)
#endif
#ifndef __deref_opt_out_ecount_part_opt
#define __nvapi_undef__deref_opt_out_ecount_part_opt
#define __deref_opt_out_ecount_part_opt(size,length)
#endif
#ifndef __deref_opt_out_bcount_part_opt
#define __nvapi_undef__deref_opt_out_bcount_part_opt
#define __deref_opt_out_bcount_part_opt(size,length)
#endif
#ifndef __deref_opt_out_ecount_full_opt
#define __nvapi_undef__deref_opt_out_ecount_full_opt
#define __deref_opt_out_ecount_full_opt(size)
#endif
#ifndef __deref_opt_out_bcount_full_opt
#define __nvapi_undef__deref_opt_out_bcount_full_opt
#define __deref_opt_out_bcount_full_opt(size)
#endif
#ifndef __deref_opt_out_z_opt
#define __nvapi_undef__deref_opt_out_z_opt
#define __deref_opt_out_z_opt
#endif
#ifndef __deref_opt_out_ecount_z_opt
#define __nvapi_undef__deref_opt_out_ecount_z_opt
#define __deref_opt_out_ecount_z_opt(size)
#endif
#ifndef __deref_opt_out_bcount_z_opt
#define __nvapi_undef__deref_opt_out_bcount_z_opt
#define __deref_opt_out_bcount_z_opt(size)
#endif
#ifndef __deref_opt_out_nz_opt
#define __nvapi_undef__deref_opt_out_nz_opt
#define __deref_opt_out_nz_opt
#endif
#ifndef __deref_opt_out_ecount_nz_opt
#define __nvapi_undef__deref_opt_out_ecount_nz_opt
#define __deref_opt_out_ecount_nz_opt(size)
#endif
#ifndef __deref_opt_out_bcount_nz_opt
#define __nvapi_undef__deref_opt_out_bcount_nz_opt
#define __deref_opt_out_bcount_nz_opt(size)
#endif
#ifndef __deref_opt_inout_opt
#define __nvapi_undef__deref_opt_inout_opt
#define __deref_opt_inout_opt
#endif
#ifndef __deref_opt_inout_ecount_opt
#define __nvapi_undef__deref_opt_inout_ecount_opt
#define __deref_opt_inout_ecount_opt(size)
#endif
#ifndef __deref_opt_inout_bcount_opt
#define __nvapi_undef__deref_opt_inout_bcount_opt
#define __deref_opt_inout_bcount_opt(size)
#endif
#ifndef __deref_opt_inout_ecount_part_opt
#define __nvapi_undef__deref_opt_inout_ecount_part_opt
#define __deref_opt_inout_ecount_part_opt(size,length)
#endif
#ifndef __deref_opt_inout_bcount_part_opt
#define __nvapi_undef__deref_opt_inout_bcount_part_opt
#define __deref_opt_inout_bcount_part_opt(size,length)
#endif
#ifndef __deref_opt_inout_ecount_full_opt
#define __nvapi_undef__deref_opt_inout_ecount_full_opt
#define __deref_opt_inout_ecount_full_opt(size)
#endif
#ifndef __deref_opt_inout_bcount_full_opt
#define __nvapi_undef__deref_opt_inout_bcount_full_opt
#define __deref_opt_inout_bcount_full_opt(size)
#endif
#ifndef __deref_opt_inout_z_opt
#define __nvapi_undef__deref_opt_inout_z_opt
#define __deref_opt_inout_z_opt
#endif
#ifndef __deref_opt_inout_ecount_z_opt
#define __nvapi_undef__deref_opt_inout_ecount_z_opt
#define __deref_opt_inout_ecount_z_opt(size)
#endif
#ifndef __deref_opt_inout_bcount_z_opt
#define __nvapi_undef__deref_opt_inout_bcount_z_opt
#define __deref_opt_inout_bcount_z_opt(size)
#endif
#ifndef __deref_opt_inout_nz_opt
#define __nvapi_undef__deref_opt_inout_nz_opt
#define __deref_opt_inout_nz_opt
#endif
#ifndef __deref_opt_inout_ecount_nz_opt
#define __nvapi_undef__deref_opt_inout_ecount_nz_opt
#define __deref_opt_inout_ecount_nz_opt(size)
#endif
#ifndef __deref_opt_inout_bcount_nz_opt
#define __nvapi_undef__deref_opt_inout_bcount_nz_opt
#define __deref_opt_inout_bcount_nz_opt(size)
#endif
#ifndef __success
#define __nvapi_success
#define __success(epxr)
#endif
#ifndef _Ret_notnull_
#define __nvapi__Ret_notnull_
#define _Ret_notnull_
#endif
#ifndef _Post_writable_byte_size_
#define __nvapi__Post_writable_byte_size_
#define _Post_writable_byte_size_(n)
#endif
#ifndef _Outptr_
#define __nvapi_Outptr_
#define _Outptr_
#endif
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl

View File

@@ -0,0 +1,247 @@
/*********************************************************************************************************\
|* *|
|* SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. *|
|* SPDX-License-Identifier: MIT *|
|* *|
|* 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"imports/nvapi/nvapi_lite_salstart.h"
#include"imports/nvapi/nvapi_lite_common.h"
#pragma pack(push,8)
#ifdef __cplusplus
extern "C" {
#endif
//-----------------------------------------------------------------------------
// DirectX APIs
//-----------------------------------------------------------------------------
//! \ingroup dx
//! Used in NvAPI_D3D10_GetCurrentSLIState(), and NvAPI_D3D_GetCurrentSLIState().
typedef struct
{
NvU32 version; //!< Structure version
NvU32 maxNumAFRGroups; //!< [OUT] The maximum possible value of numAFRGroups
NvU32 numAFRGroups; //!< [OUT] The number of AFR groups enabled in the system
NvU32 currentAFRIndex; //!< [OUT] The AFR group index for the frame currently being rendered
NvU32 nextFrameAFRIndex; //!< [OUT] What the AFR group index will be for the next frame (i.e. after calling Present)
NvU32 previousFrameAFRIndex; //!< [OUT] The AFR group index that was used for the previous frame (~0 if more than one frame has not been rendered yet)
NvU32 bIsCurAFRGroupNew; //!< [OUT] Boolean: Is this frame the first time running on the current AFR group
} NV_GET_CURRENT_SLI_STATE_V1;
typedef struct
{
NvU32 version; //!< Structure version
NvU32 maxNumAFRGroups; //!< [OUT] The maximum possible value of numAFRGroups
NvU32 numAFRGroups; //!< [OUT] The number of AFR groups enabled in the system
NvU32 currentAFRIndex; //!< [OUT] The AFR group index for the frame currently being rendered
NvU32 nextFrameAFRIndex; //!< [OUT] What the AFR group index will be for the next frame (i.e. after calling Present)
NvU32 previousFrameAFRIndex; //!< [OUT] The AFR group index that was used for the previous frame (~0 if more than one frame has not been rendered yet)
NvU32 bIsCurAFRGroupNew; //!< [OUT] Boolean: Is this frame the first time running on the current AFR group
NvU32 numVRSLIGpus; //!< [OUT] The number of GPUs used in VR-SLI. If it is 0 VR-SLI is not active
} NV_GET_CURRENT_SLI_STATE_V2;
//! \ingroup dx
#define NV_GET_CURRENT_SLI_STATE_VER1 MAKE_NVAPI_VERSION(NV_GET_CURRENT_SLI_STATE_V1,1)
#define NV_GET_CURRENT_SLI_STATE_VER2 MAKE_NVAPI_VERSION(NV_GET_CURRENT_SLI_STATE_V2,1)
#define NV_GET_CURRENT_SLI_STATE_VER NV_GET_CURRENT_SLI_STATE_VER2
#define NV_GET_CURRENT_SLI_STATE NV_GET_CURRENT_SLI_STATE_V2
#if defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__)
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_D3D_GetCurrentSLIState
//
//! DESCRIPTION: This function returns the current SLI state for the specified device. The structure
//! contains the number of AFR groups, the current AFR group index,
//! and what the AFR group index will be for the next frame. \p
//! pDevice can be either a IDirect3DDevice9 or ID3D10Device pointer.
//!
//! SUPPORTED OS: Windows 10 and higher
//!
//!
//! \since Release: 173
//!
//! \retval NVAPI_OK Completed request
//! \retval NVAPI_ERROR Error occurred
//!
//! \ingroup dx
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_D3D_GetCurrentSLIState(IUnknown *pDevice, NV_GET_CURRENT_SLI_STATE *pSliState);
#endif //if defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__)
#if defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__)
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_D3D_SetResourceHint
//
//! \fn NvAPI_D3D_SetResourceHint(IUnknown *pDev, NVDX_ObjectHandle obj,
//! NVAPI_D3D_SETRESOURCEHINT_CATEGORY dwHintCategory,
//! NvU32 dwHintName,
//! NvU32 *pdwHintValue)
//!
//! DESCRIPTION: This is a general purpose function for passing down various resource
//! related hints to the driver. Hints are divided into categories
//! and types within each category. For DX11 devices this function is free-threaded.
//! An application is responsible to complete this call before making use of the resource
//! in a rendering context (therefore applying inter-thread synchronization as appropriate).
//! As a debug help to an application the driver enforces that a resource in this call was never bound.
//!
//! SUPPORTED OS: Windows 10 and higher
//!
//!
//! \since Release: 185
//!
//! \param [in] pDev The ID3D10Device or IDirect3DDevice9 that is a using the resource
//! \param [in] obj Previously obtained HV resource handle
//! \param [in] dwHintCategory Category of the hints
//! \param [in] dwHintName A hint within this category
//! \param [in/out] *pdwHintValue Pointer to location containing hint value, function returns previous hint value in this slot
//!
//! \return an int which could be an NvAPI status or DX HRESULT code
//!
//! \retval ::NVAPI_OK
//! \retval ::NVAPI_INVALID_ARGUMENT
//! \retval ::NVAPI_INVALID_CALL It is illegal to change a hint dynamically when the resource is already bound.
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//! \ingroup dx
//! Valid categories for NvAPI_D3D_SetResourceHint()
typedef enum _NVAPI_D3D_SETRESOURCEHINT_CATEGORY
{
NVAPI_D3D_SRH_CATEGORY_SLI = 1
} NVAPI_D3D_SETRESOURCEHINT_CATEGORY;
//
// NVAPI_D3D_SRH_SLI_APP_CONTROLLED_INTERFRAME_CONTENT_SYNC:
// NVAPI_D3D_SRH_SLI_ASK_FOR_BROADCAST_USING:
// NVAPI_D3D_SRH_SLI_RESPECT_DRIVER_INTERFRAME_CONTENT_SYNC:
//! \ingroup dx
//! Types of SLI hints; \n
//! NVAPI_D3D_SRH_SLI_APP_CONTROLLED_INTERFRAME_CONTENT_SYNC: Valid values : 0 or 1 \n
//! Default value: 0 \n
//! Explanation: If the value is 1, the driver will not track any rendering operations that would mark this resource as dirty,
//! avoiding any form of synchronization across frames rendered in parallel in multiple GPUs in AFR mode.
//!
//! NVAPI_D3D_SRH_SLI_ASK_FOR_BROADCAST_USAGE: Valid values : 0 or 1 \n
//! Default value: 0 \n
//! Explanation: If the value is 1, the driver will try to perform operations which involved target resource in broadcast,
//! where it's possible. Hint is static and must be set before resource starts using.
//!
//! NVAPI_D3D_SRH_SLI_RESPECT_DRIVER_INTERFRAME_CONTENT_SYNC: Valid values : 0 or 1 \n
//! Default value: 0 \n
//! Explanation: If the value is 1, the driver will do dirty resource resolve regardless of discard flags in the application profile or
//! AFR-FriendlyD3DHints.exe name using.
//!
typedef enum _NVAPI_D3D_SETRESOURCEHINT_SLI
{
NVAPI_D3D_SRH_SLI_APP_CONTROLLED_INTERFRAME_CONTENT_SYNC = 1,
NVAPI_D3D_SRH_SLI_ASK_FOR_BROADCAST_USAGE = 2,
NVAPI_D3D_SRH_SLI_RESPECT_DRIVER_INTERFRAME_CONTENT_SYNC = 3
} NVAPI_D3D_SETRESOURCEHINT_SLI;
//! \ingroup dx
NVAPI_INTERFACE NvAPI_D3D_SetResourceHint(IUnknown *pDev, NVDX_ObjectHandle obj,
NVAPI_D3D_SETRESOURCEHINT_CATEGORY dwHintCategory,
NvU32 dwHintName,
NvU32 *pdwHintValue);
#endif //defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__)
#if defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__)
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_D3D_BeginResourceRendering
//
//! \fn NvAPI_D3D_BeginResourceRendering(IUnknown *pDeviceOrContext, NVDX_ObjectHandle obj, NvU32 Flags)
//! DESCRIPTION: This function tells the driver that the resource will begin to receive updates. It must be used in combination with NvAPI_D3D_EndResourceRendering().
//! The primary use of this function is allow the driver to initiate early inter-frame synchronization of resources while running in AFR SLI mode.
//!
//! SUPPORTED OS: Windows 10 and higher
//!
//!
//! \since Release: 185
//!
//! \param [in] pDev IDirect3DDevice9, ID3D10Device, ID3D11Device or ID3D11DeviceContext that is using the resource
//! \param [in] obj Previously obtained HV resource handle
//! \param [in] Flags The flags for functionality applied to resource while being used.
//!
//! \retval ::NVAPI_OK Function succeeded, if used properly and driver can initiate proper sync'ing of the resources.
//! \retval ::NVAPI_INVALID_ARGUMENT Bad argument(s) or invalid flag values
//! \retval ::NVAPI_INVALID_CALL Mismatched begin/end calls
//
///////////////////////////////////////////////////////////////////////////////
//! \ingroup dx
//! Used in NvAPI_D3D_BeginResourceRendering().
typedef enum _NVAPI_D3D_RESOURCERENDERING_FLAG
{
NVAPI_D3D_RR_FLAG_DEFAULTS = 0x00000000, //!< All bits set to 0 are defaults.
NVAPI_D3D_RR_FLAG_FORCE_DISCARD_CONTENT = 0x00000001, //!< (bit 0) The flag forces to discard previous content of the resource regardless of the NvApiHints_Sli_Disable_InterframeSync hint
NVAPI_D3D_RR_FLAG_FORCE_KEEP_CONTENT = 0x00000002, //!< (bit 1) The flag forces to respect previous content of the resource regardless of the NvApiHints_Sli_Disable_InterframeSync hint
NVAPI_D3D_RR_FLAG_MULTI_FRAME = 0x00000004 //!< (bit 2) The flag hints the driver that content will be used for many frames. If not specified then the driver assumes that content is used only on the next frame
} NVAPI_D3D_RESOURCERENDERING_FLAG;
//! \ingroup dx
NVAPI_INTERFACE NvAPI_D3D_BeginResourceRendering(IUnknown *pDeviceOrContext, NVDX_ObjectHandle obj, NvU32 Flags);
#endif //defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__)
#if defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__)
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_D3D_EndResourceRendering
//
//! DESCRIPTION: This function tells the driver that the resource is done receiving updates. It must be used in combination with
//! NvAPI_D3D_BeginResourceRendering().
//! The primary use of this function is allow the driver to initiate early inter-frame syncs of resources while running in AFR SLI mode.
//!
//! SUPPORTED OS: Windows 10 and higher
//!
//!
//! \since Release: 185
//!
//! \param [in] pDev IDirect3DDevice9, ID3D10Device, ID3D11Device or ID3D11DeviceContext that is using the resource
//! \param [in] obj Previously obtained HV resource handle
//! \param [in] Flags Reserved, must be zero
//
//! \retval ::NVAPI_OK Function succeeded, if used properly and driver can initiate proper sync'ing of the resources.
//! \retval ::NVAPI_INVALID_ARGUMENT Bad argument(s) or invalid flag values
//! \retval ::NVAPI_INVALID_CALL Mismatched begin/end calls
//!
//! \ingroup dx
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_D3D_EndResourceRendering(IUnknown *pDeviceOrContext, NVDX_ObjectHandle obj, NvU32 Flags);
#endif //if defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__)
#include"imports/nvapi/nvapi_lite_salend.h"
#ifdef __cplusplus
}
#endif
#pragma pack(pop)

View File

@@ -0,0 +1,592 @@
/*********************************************************************************************************\
|* *|
|* SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. *|
|* SPDX-License-Identifier: MIT *|
|* *|
|* 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"imports/nvapi/nvapi_lite_salstart.h"
#include"imports/nvapi/nvapi_lite_common.h"
#pragma pack(push,8)
#ifdef __cplusplus
extern "C" {
#endif
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_Stereo_Enable
//
//! DESCRIPTION: This APU enables stereo mode in the registry.
//! Calls to this function affect the entire system.
//! If stereo is not enabled, then calls to functions that require that stereo is enabled have no effect,
//! and will return the appropriate error code.
//!
//! SUPPORTED OS: Windows 10 and higher
//!
//!
//! \since Release: 180
//!
//! \retval ::NVAPI_OK Stereo is now enabled.
//! \retval ::NVAPI_API_NOT_INTIALIZED
//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized.
//! \retval ::NVAPI_ERROR
//!
//! \ingroup stereoapi
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_Stereo_Enable(void);
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_Stereo_Disable
//
//! DESCRIPTION: This API disables stereo mode in the registry.
//! Calls to this function affect the entire system.
//! If stereo is not enabled, then calls to functions that require that stereo is enabled have no effect,
//! and will return the appropriate error code.
//!
//! SUPPORTED OS: Windows 10 and higher
//!
//!
//! \since Release: 180
//!
//! \retval ::NVAPI_OK Stereo is now disabled.
//! \retval ::NVAPI_API_NOT_INTIALIZED
//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized.
//! \retval ::NVAPI_ERROR
//!
//! \ingroup stereoapi
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_Stereo_Disable(void);
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_Stereo_IsEnabled
//
//! DESCRIPTION: This API checks if stereo mode is enabled in the registry.
//!
//! SUPPORTED OS: Windows 10 and higher
//!
//!
//! \since Release: 180
//!
//! \param [out] pIsStereoEnabled Address where the result of the inquiry will be placed.
//!
//! \retval ::NVAPI_OK Check was sucessfully completed and result reflects current state of stereo availability.
//! \retval ::NVAPI_API_NOT_INTIALIZED
//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized.
//! \retval ::NVAPI_ERROR
//!
//! \ingroup stereoapi
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_Stereo_IsEnabled(NvU8 *pIsStereoEnabled);
#if defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__)|| defined(__d3d12_h__)
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_Stereo_CreateHandleFromIUnknown
//
//! DESCRIPTION: This API creates a stereo handle that is used in subsequent calls related to a given device interface.
//! This must be called before any other NvAPI_Stereo_ function for that handle.
//! Multiple devices can be used at one time using multiple calls to this function (one per each device).
//!
//! HOW TO USE: After the Direct3D device is created, create the stereo handle.
//! On call success:
//! -# Use all other NvAPI_Stereo_ functions that have stereo handle as first parameter.
//! -# After the device interface that corresponds to the the stereo handle is destroyed,
//! the application should call NvAPI_DestroyStereoHandle() for that stereo handle.
//!
//! WHEN TO USE: After the stereo handle for the device interface is created via successfull call to the appropriate NvAPI_Stereo_CreateHandleFrom() function.
//!
//! SUPPORTED OS: Windows 10 and higher
//!
//!
//! \since Release: 180
//!
//! \param [in] pDevice Pointer to IUnknown interface that is IDirect3DDevice9* in DX9, ID3D10Device*.
//! \param [out] pStereoHandle Pointer to the newly created stereo handle.
//!
//! \retval ::NVAPI_OK Stereo handle is created for given device interface.
//! \retval ::NVAPI_INVALID_ARGUMENT Provided device interface is invalid.
//! \retval ::NVAPI_API_NOT_INTIALIZED
//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized.
//! \retval ::NVAPI_ERROR
//!
//! \ingroup stereoapi
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_Stereo_CreateHandleFromIUnknown(IUnknown *pDevice, StereoHandle *pStereoHandle);
#endif // defined(_D3D9_H_) || defined(__d3d10_h__)
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_Stereo_DestroyHandle
//
//! DESCRIPTION: This API destroys the stereo handle created with one of the NvAPI_Stereo_CreateHandleFrom() functions.
//! This should be called after the device corresponding to the handle has been destroyed.
//!
//! SUPPORTED OS: Windows 10 and higher
//!
//!
//! \since Release: 180
//!
//! \param [in] stereoHandle Stereo handle that is to be destroyed.
//!
//! \retval ::NVAPI_OK Stereo handle is destroyed.
//! \retval ::NVAPI_API_NOT_INTIALIZED
//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized.
//! \retval ::NVAPI_ERROR
//!
//! \ingroup stereoapi
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_Stereo_DestroyHandle(StereoHandle stereoHandle);
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_Stereo_Activate
//
//! DESCRIPTION: This API activates stereo for the device interface corresponding to the given stereo handle.
//! Activating stereo is possible only if stereo was enabled previously in the registry.
//! If stereo is not activated, then calls to functions that require that stereo is activated have no effect,
//! and will return the appropriate error code.
//!
//! WHEN TO USE: After the stereo handle for the device interface is created via successfull call to the appropriate NvAPI_Stereo_CreateHandleFrom() function.
//!
//! SUPPORTED OS: Windows 10 and higher
//!
//!
//! \since Release: 180
//!
//! \param [in] stereoHandle Stereo handle corresponding to the device interface.
//!
//! \retval ::NVAPI_OK Stereo is turned on.
//! \retval ::NVAPI_STEREO_INVALID_DEVICE_INTERFACE Device interface is not valid. Create again, then attach again.
//! \retval ::NVAPI_API_NOT_INTIALIZED
//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized.
//! \retval ::NVAPI_ERROR
//!
//! \ingroup stereoapi
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_Stereo_Activate(StereoHandle stereoHandle);
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_Stereo_Deactivate
//
//! DESCRIPTION: This API deactivates stereo for the given device interface.
//! If stereo is not activated, then calls to functions that require that stereo is activated have no effect,
//! and will return the appropriate error code.
//!
//! WHEN TO USE: After the stereo handle for the device interface is created via successfull call to the appropriate NvAPI_Stereo_CreateHandleFrom() function.
//!
//! SUPPORTED OS: Windows 10 and higher
//!
//!
//! \since Release: 180
//!
//! \param [in] stereoHandle Stereo handle that corresponds to the device interface.
//!
//! \retval ::NVAPI_OK Stereo is turned off.
//! \retval ::NVAPI_STEREO_INVALID_DEVICE_INTERFACE Device interface is not valid. Create again, then attach again.
//! \retval ::NVAPI_API_NOT_INTIALIZED
//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized.
//! \retval ::NVAPI_ERROR
//!
//! \ingroup stereoapi
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_Stereo_Deactivate(StereoHandle stereoHandle);
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_Stereo_IsActivated
//
//! DESCRIPTION: This API checks if stereo is activated for the given device interface.
//!
//! WHEN TO USE: After the stereo handle for the device interface is created via successfull call to the appropriate NvAPI_Stereo_CreateHandleFrom() function.
//!
//! SUPPORTED OS: Windows 10 and higher
//!
//!
//! \since Release: 180
//!
//! \param [in] stereoHandle Stereo handle that corresponds to the device interface.
//! \param [in] pIsStereoOn Address where result of the inquiry will be placed.
//!
//! \retval ::NVAPI_OK - Check was sucessfully completed and result reflects current state of stereo (on/off).
//! \retval ::NVAPI_STEREO_INVALID_DEVICE_INTERFACE - Device interface is not valid. Create again, then attach again.
//! \retval ::NVAPI_API_NOT_INTIALIZED - NVAPI not initialized.
//! \retval ::NVAPI_STEREO_NOT_INITIALIZED - Stereo part of NVAPI not initialized.
//! \retval ::NVAPI_ERROR - Something is wrong (generic error).
//!
//! \ingroup stereoapi
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_Stereo_IsActivated(StereoHandle stereoHandle, NvU8 *pIsStereoOn);
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_Stereo_GetSeparation
//
//! DESCRIPTION: This API gets current separation value (in percents).
//!
//! WHEN TO USE: After the stereo handle for the device interface is created via successfull call to the appropriate NvAPI_Stereo_CreateHandleFrom() function.
//!
//! SUPPORTED OS: Windows 10 and higher
//!
//!
//! \since Release: 180
//!
//! \param [in] stereoHandle Stereo handle that corresponds to the device interface.
//! \param [out] pSeparationPercentage Address of @c float type variable to store current separation percentage in.
//!
//! \retval ::NVAPI_OK Retrieval of separation percentage was successfull.
//! \retval ::NVAPI_STEREO_INVALID_DEVICE_INTERFACE Device interface is not valid. Create again, then attach again.
//! \retval ::NVAPI_API_NOT_INTIALIZED
//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized.
//! \retval ::NVAPI_ERROR
//!
//! \ingroup stereoapi
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_Stereo_GetSeparation(StereoHandle stereoHandle, float *pSeparationPercentage);
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_Stereo_SetSeparation
//
//! DESCRIPTION: This API sets separation to given percentage.
//!
//! WHEN TO USE: After the stereo handle for the device interface is created via successfull call to appropriate NvAPI_Stereo_CreateHandleFrom() function.
//!
//! SUPPORTED OS: Windows 10 and higher
//!
//!
//! \since Release: 180
//!
//! \param [in] stereoHandle Stereo handle that corresponds to the device interface.
//! \param [in] newSeparationPercentage New value for separation percentage.
//!
//! \retval ::NVAPI_OK Setting of separation percentage was successfull.
//! \retval ::NVAPI_STEREO_INVALID_DEVICE_INTERFACE Device interface is not valid. Create again, then attach again.
//! \retval ::NVAPI_API_NOT_INTIALIZED NVAPI not initialized.
//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized.
//! \retval ::NVAPI_STEREO_PARAMETER_OUT_OF_RANGE Given separation percentage is out of [0..100] range.
//! \retval ::NVAPI_ERROR
//!
//! \ingroup stereoapi
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_Stereo_SetSeparation(StereoHandle stereoHandle, float newSeparationPercentage);
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_Stereo_GetConvergence
//
//! DESCRIPTION: This API gets the current convergence value.
//!
//! WHEN TO USE: After the stereo handle for the device interface is created via successfull call to the appropriate NvAPI_Stereo_CreateHandleFrom() function.
//!
//! SUPPORTED OS: Windows 10 and higher
//!
//!
//! \since Release: 180
//!
//! \param [in] stereoHandle Stereo handle that corresponds to the device interface.
//! \param [out] pConvergence Address of @c float type variable to store current convergence value in.
//!
//! \retval ::NVAPI_OK Retrieval of convergence value was successfull.
//! \retval ::NVAPI_STEREO_INVALID_DEVICE_INTERFACE Device interface is not valid. Create again, then attach again.
//! \retval ::NVAPI_API_NOT_INTIALIZED
//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized.
//! \retval ::NVAPI_ERROR
//!
//! \ingroup stereoapi
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_Stereo_GetConvergence(StereoHandle stereoHandle, float *pConvergence);
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_Stereo_SetConvergence
//
//! DESCRIPTION: This API sets convergence to the given value.
//!
//! WHEN TO USE: After the stereo handle for the device interface is created via successfull call to the appropriate NvAPI_Stereo_CreateHandleFrom() function.
//!
//! SUPPORTED OS: Windows 10 and higher
//!
//!
//! \since Release: 180
//!
//! \param [in] stereoHandle Stereo handle that corresponds to the device interface.
//! \param [in] newConvergence New value for convergence.
//!
//! \retval ::NVAPI_OK Setting of convergence value was successfull.
//! \retval ::NVAPI_STEREO_INVALID_DEVICE_INTERFACE Device interface is not valid. Create again, then attach again.
//! \retval ::NVAPI_API_NOT_INTIALIZED
//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized.
//! \retval ::NVAPI_ERROR
//!
//! \ingroup stereoapi
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_Stereo_SetConvergence(StereoHandle stereoHandle, float newConvergence);
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_Stereo_SetActiveEye
//
//! \fn NvAPI_Stereo_SetActiveEye(StereoHandle hStereoHandle, NV_STEREO_ACTIVE_EYE StereoEye);
//! DESCRIPTION: This API sets the back buffer to left or right in Direct stereo mode.
//!
//! HOW TO USE: After the stereo handle for device interface is created via successfull call to appropriate
//! NvAPI_Stereo_CreateHandleFrom function.
//!
//! \since Release: 285
//!
//! SUPPORTED OS: Windows 10 and higher
//!
//!
//! \param [in] stereoHandle Stereo handle that corresponds to the device interface.
//! \param [in] StereoEye Defines active eye in Direct stereo mode
//!
//! \retval ::NVAPI_OK - Active eye is set.
//! \retval ::NVAPI_STEREO_INVALID_DEVICE_INTERFACE - Device interface is not valid. Create again, then attach again.
//! \retval ::NVAPI_API_NOT_INTIALIZED - NVAPI not initialized.
//! \retval ::NVAPI_STEREO_NOT_INITIALIZED - Stereo part of NVAPI not initialized.
//! \retval ::NVAPI_INVALID_ARGUMENT - StereoEye parameter has not allowed value.
//! \retval ::NVAPI_SET_NOT_ALLOWED - Current stereo mode is not Direct
//! \retval ::NVAPI_ERROR - Something is wrong (generic error).
//
///////////////////////////////////////////////////////////////////////////////
//! \ingroup stereoapi
typedef enum _NV_StereoActiveEye
{
NVAPI_STEREO_EYE_RIGHT = 1,
NVAPI_STEREO_EYE_LEFT = 2,
NVAPI_STEREO_EYE_MONO = 3,
} NV_STEREO_ACTIVE_EYE;
//! \ingroup stereoapi
NVAPI_INTERFACE NvAPI_Stereo_SetActiveEye(StereoHandle hStereoHandle, NV_STEREO_ACTIVE_EYE StereoEye);
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_Stereo_SetDriverMode
//
//! \fn NvAPI_Stereo_SetDriverMode( NV_STEREO_DRIVER_MODE mode );
//! DESCRIPTION: This API sets the 3D stereo driver mode: Direct or Automatic
//!
//! HOW TO USE: This API must be called before the device is created.
//! Applies to DirectX 9 and higher.
//!
//! \since Release: 285
//!
//! SUPPORTED OS: Windows 10 and higher
//!
//!
//! \param [in] mode Defines the 3D stereo driver mode: Direct or Automatic
//!
//! \retval ::NVAPI_OK Active eye is set.
//! \retval ::NVAPI_API_NOT_INTIALIZED NVAPI not initialized.
//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized.
//! \retval ::NVAPI_INVALID_ARGUMENT mode parameter has not allowed value.
//! \retval ::NVAPI_ERROR Something is wrong (generic error).
//
///////////////////////////////////////////////////////////////////////////////
//! \ingroup stereoapi
typedef enum _NV_StereoDriverMode
{
NVAPI_STEREO_DRIVER_MODE_AUTOMATIC = 0,
NVAPI_STEREO_DRIVER_MODE_DIRECT = 2,
} NV_STEREO_DRIVER_MODE;
//! \ingroup stereoapi
NVAPI_INTERFACE NvAPI_Stereo_SetDriverMode( NV_STEREO_DRIVER_MODE mode );
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_Stereo_GetEyeSeparation
//
//! DESCRIPTION: This API returns eye separation as a ratio of <between eye distance>/<physical screen width>.
//!
//! HOW TO USE: After the stereo handle for device interface is created via successfull call to appropriate API. Applies only to DirectX 9 and up.
//!
//! SUPPORTED OS: Windows 10 and higher
//!
//!
//! \param [in] stereoHandle Stereo handle that corresponds to the device interface.
//! \param [out] pSeparation Eye separation.
//!
//! \retval ::NVAPI_OK Active eye is set.
//! \retval ::NVAPI_STEREO_INVALID_DEVICE_INTERFACE Device interface is not valid. Create again, then attach again.
//! \retval ::NVAPI_API_NOT_INTIALIZED NVAPI not initialized.
//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized.
//! \retval ::NVAPI_ERROR (generic error).
//!
//! \ingroup stereoapi
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_Stereo_GetEyeSeparation(StereoHandle hStereoHandle, float *pSeparation );
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_Stereo_IsWindowedModeSupported
//
//! DESCRIPTION: This API returns availability of windowed mode stereo
//!
//! SUPPORTED OS: Windows 10 and higher
//!
//!
//! \param [out] bSupported(OUT) != 0 - supported, \n
//! == 0 - is not supported
//!
//!
//! \retval ::NVAPI_OK Retrieval of frustum adjust mode was successfull.
//! \retval ::NVAPI_API_NOT_INTIALIZED NVAPI not initialized.
//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized.
//! \retval ::NVAPI_ERROR Something is wrong (generic error).
//!
//! \ingroup stereoapi
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_Stereo_IsWindowedModeSupported(NvU8* bSupported);
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_Stereo_SetSurfaceCreationMode
//
//! \function NvAPI_Stereo_SetSurfaceCreationMode(StereoHandle hStereoHandle, NVAPI_STEREO_SURFACECREATEMODE creationMode)
//! \param [in] hStereoHandle Stereo handle that corresponds to the device interface.
//! \param [in] creationMode New surface creation mode for this device interface.
//!
//! \since Release: 285
//!
//! SUPPORTED OS: Windows 10 and higher
//!
//!
//! DESCRIPTION: This API sets surface creation mode for this device interface.
//!
//! WHEN TO USE: After the stereo handle for device interface is created via successful call to appropriate NvAPI_Stereo_CreateHandleFrom function.
//!
//! \return This API can return any of the error codes enumerated in #NvAPI_Status.
//! There are no return error codes with specific meaning for this API.
//!
///////////////////////////////////////////////////////////////////////////////
//! \ingroup stereoapi
typedef enum _NVAPI_STEREO_SURFACECREATEMODE
{
NVAPI_STEREO_SURFACECREATEMODE_AUTO, //!< Use driver registry profile settings for surface creation mode.
NVAPI_STEREO_SURFACECREATEMODE_FORCESTEREO, //!< Always create stereo surfaces.
NVAPI_STEREO_SURFACECREATEMODE_FORCEMONO //!< Always create mono surfaces.
} NVAPI_STEREO_SURFACECREATEMODE;
//! \ingroup stereoapi
NVAPI_INTERFACE NvAPI_Stereo_SetSurfaceCreationMode(__in StereoHandle hStereoHandle, __in NVAPI_STEREO_SURFACECREATEMODE creationMode);
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_Stereo_GetSurfaceCreationMode
//
//! \function NvAPI_Stereo_GetSurfaceCreationMode(StereoHandle hStereoHandle, NVAPI_STEREO_SURFACECREATEMODE* pCreationMode)
//! \param [in] hStereoHandle Stereo handle that corresponds to the device interface.
//! \param [out] pCreationMode The current creation mode for this device interface.
//!
//! \since Release: 295
//!
//! SUPPORTED OS: Windows 10 and higher
//!
//!
//! DESCRIPTION: This API gets surface creation mode for this device interface.
//!
//! WHEN TO USE: After the stereo handle for device interface is created via successful call to appropriate NvAPI_Stereo_CreateHandleFrom function.
//!
//! \return This API can return any of the error codes enumerated in #NvAPI_Status.
//! There are no return error codes with specific meaning for this API.
//!
///////////////////////////////////////////////////////////////////////////////
//! \ingroup stereoapi
NVAPI_INTERFACE NvAPI_Stereo_GetSurfaceCreationMode(__in StereoHandle hStereoHandle, __in NVAPI_STEREO_SURFACECREATEMODE* pCreationMode);
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_Stereo_Debug_WasLastDrawStereoized
//
//! \param [in] hStereoHandle Stereo handle that corresponds to the device interface.
//! \param [out] pWasStereoized Address where result of the inquiry will be placed.
//!
//! SUPPORTED OS: Windows 10 and higher
//!
//!
//! DESCRIPTION: This API checks if the last draw call was stereoized. It is a very expensive to call and should be used for debugging purpose *only*.
//!
//! WHEN TO USE: After the stereo handle for device interface is created via successful call to appropriate NvAPI_Stereo_CreateHandleFrom function.
//!
//! \return This API can return any of the error codes enumerated in #NvAPI_Status.
//! There are no return error codes with specific meaning for this API.
//!
//! \ingroup stereoapi
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_Stereo_Debug_WasLastDrawStereoized(__in StereoHandle hStereoHandle, __out NvU8 *pWasStereoized);
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_Stereo_SetDefaultProfile
//
//!
//! SUPPORTED OS: Windows 10 and higher
//!
//!
//! DESCRIPTION: This API defines the stereo profile used by the driver in case the application has no associated profile.
//!
//! WHEN TO USE: To take effect, this API must be called before D3D device is created. Calling once a device has been created will not affect the current device.
//!
//! \param [in] szProfileName Default profile name.
//!
//! \return This API can return any of the error codes enumerated in #NvAPI_Status.
//! Error codes specific to this API are described below.
//!
//! \retval NVAPI_SUCCESS - Default stereo profile name has been copied into szProfileName.
//! \retval NVAPI_INVALID_ARGUMENT - szProfileName == NULL.
//! \retval NVAPI_DEFAULT_STEREO_PROFILE_DOES_NOT_EXIST - Default stereo profile does not exist
//!
//! \ingroup stereoapi
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_Stereo_SetDefaultProfile(__in const char* szProfileName);
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_Stereo_GetDefaultProfile
//
//! SUPPORTED OS: Windows 10 and higher
//!
//!
//! DESCRIPTION: This API retrieves the current default stereo profile.
//!
//! After call cbSizeOut contain 0 if default profile is not set required buffer size cbSizeOut.
//! To get needed buffer size this function can be called with szProfileName==0 and cbSizeIn == 0.
//!
//! WHEN TO USE: This API can be called at any time.
//!
//!
//! \param [in] cbSizeIn Size of buffer allocated for default stereo profile name.
//! \param [out] szProfileName Default stereo profile name.
//! \param [out] pcbSizeOut Required buffer size.
//! # ==0 - there is no default stereo profile name currently set
//! # !=0 - size of buffer required for currently set default stereo profile name including trailing '0'.
//!
//!
//! \return This API can return any of the error codes enumerated in #NvAPI_Status.
//! Error codes specific to this API are described below.
//!
//! \retval NVAPI_SUCCESS - Default stereo profile name has been copied into szProfileName.
//! \retval NVAPI_DEFAULT_STEREO_PROFILE_IS_NOT_DEFINED - There is no default stereo profile set at this time.
//! \retval NVAPI_INVALID_ARGUMENT - pcbSizeOut == 0 or cbSizeIn >= *pcbSizeOut && szProfileName == 0
//! \retval NVAPI_INSUFFICIENT_BUFFER - cbSizeIn < *pcbSizeOut
//!
//! \ingroup stereoapi
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_Stereo_GetDefaultProfile( __in NvU32 cbSizeIn, __out_bcount_part_opt(cbSizeIn, *pcbSizeOut) char* szProfileName, __out NvU32 *pcbSizeOut);
#include"imports/nvapi/nvapi_lite_salend.h"
#ifdef __cplusplus
}
#endif
#pragma pack(pop)

View File

@@ -0,0 +1,95 @@
/*********************************************************************************************************\
|* *|
|* SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. *|
|* SPDX-License-Identifier: MIT *|
|* *|
|* 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"imports/nvapi/nvapi_lite_salstart.h"
#include"imports/nvapi/nvapi_lite_common.h"
#pragma pack(push,8)
#ifdef __cplusplus
extern "C" {
#endif
//! SUPPORTED OS: Windows 10 and higher
//!
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_DISP_GetGDIPrimaryDisplayId
//
//! DESCRIPTION: This API returns the Display ID of the GDI Primary.
//!
//! \param [out] displayId Display ID of the GDI Primary display.
//!
//! \retval ::NVAPI_OK: Capabilties have been returned.
//! \retval ::NVAPI_NVIDIA_DEVICE_NOT_FOUND: GDI Primary not on an NVIDIA GPU.
//! \retval ::NVAPI_INVALID_ARGUMENT: One or more args passed in are invalid.
//! \retval ::NVAPI_API_NOT_INTIALIZED: The NvAPI API needs to be initialized first
//! \retval ::NVAPI_NO_IMPLEMENTATION: This entrypoint not available
//! \retval ::NVAPI_ERROR: Miscellaneous error occurred
//!
//! \ingroup dispcontrol
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_DISP_GetGDIPrimaryDisplayId(NvU32* displayId);
#define NV_MOSAIC_MAX_DISPLAYS (64)
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_Mosaic_GetDisplayViewportsByResolution
//
//! DESCRIPTION: This API returns the viewports that would be applied on
//! the requested display.
//!
//! \param [in] displayId Display ID of a single display in the active
//! mosaic topology to query.
//! \param [in] srcWidth Width of full display topology. If both
//! width and height are 0, the current
//! resolution is used.
//! \param [in] srcHeight Height of full display topology. If both
//! width and height are 0, the current
//! resolution is used.
//! \param [out] viewports Array of NV_RECT viewports.
//! SUPPORTED OS: Windows 10 and higher
//!
//! If the requested resolution is a single-wide
//! resolution, only viewports[0] will
//! contain the viewport details, regardless
//! of which display is driving the display.
//! \param [out] bezelCorrected Returns 1 if the requested resolution is
//! bezel corrected. May be NULL.
//!
//! \retval ::NVAPI_OK Capabilties have been returned.
//! \retval ::NVAPI_INVALID_ARGUMENT One or more args passed in are invalid.
//! \retval ::NVAPI_API_NOT_INTIALIZED The NvAPI API needs to be initialized first
//! \retval ::NVAPI_MOSAIC_NOT_ACTIVE The display does not belong to an active Mosaic Topology
//! \retval ::NVAPI_NO_IMPLEMENTATION This entrypoint not available
//! \retval ::NVAPI_ERROR Miscellaneous error occurred
//!
//! \ingroup mosaicapi
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_Mosaic_GetDisplayViewportsByResolution(NvU32 displayId, NvU32 srcWidth, NvU32 srcHeight, NV_RECT viewports[NV_MOSAIC_MAX_DISPLAYS], NvU8* bezelCorrected);
#include"imports/nvapi/nvapi_lite_salend.h"
#ifdef __cplusplus
}
#endif
#pragma pack(pop)

View File

@@ -3,5 +3,4 @@ libs += avs-util
libs_avs-util := \ libs_avs-util := \
src_avs-util := \ src_avs-util := \
core-interop.c \
error.c \ error.c \

View File

@@ -1,16 +0,0 @@
#include "core/log.h"
#include "core/thread.h"
#include "imports/avs.h"
void avs_util_core_interop_log_avs_impl_set()
{
core_log_impl_set(
log_body_misc, log_body_info, log_body_warning, log_body_fatal);
}
void avs_util_core_interop_thread_avs_impl_set()
{
core_thread_impl_set(
avs_thread_create, avs_thread_join, avs_thread_destroy);
}

View File

@@ -1,7 +0,0 @@
#ifndef AVS_UTIL_CORE_INTEROP_H
#define AVS_UTIL_CORE_INTEROP_H
void avs_util_core_interop_log_avs_impl_set();
void avs_util_core_interop_thread_avs_impl_set();
#endif

View File

@@ -8,4 +8,5 @@ libs_camhook := \
src_camhook := \ src_camhook := \
cam.c \ cam.c \
cam-detect.c \
config-cam.c \ config-cam.c \

View File

@@ -0,0 +1,402 @@
#define LOG_MODULE "cam-hook"
// clang-format off
// Don't format because the order is important here
#include <windows.h>
#include <initguid.h>
// clang-format on
#include <mfapi.h>
#include <mfidl.h>
#include <mfobjects.h>
#include <cfgmgr32.h>
#include <setupapi.h>
#include <stdio.h>
#include "camhook/cam-detect.h"
#include "util/defs.h"
#include "util/log.h"
#include "util/str.h"
EXTERN_GUID(
MY_MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE,
0xc60ac5fe,
0x252a,
0x478f,
0xa0,
0xef,
0xbc,
0x8f,
0xa5,
0xf7,
0xca,
0xd3);
EXTERN_GUID(
MY_MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID,
0x8ac3587a,
0x4ae7,
0x42d8,
0x99,
0xe0,
0x0a,
0x60,
0x13,
0xee,
0xf9,
0x0f);
EXTERN_GUID(
MY_MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINK,
0x58f0aad8,
0x22bf,
0x4f8a,
0xbb,
0x3d,
0xd2,
0xc4,
0x97,
0x8c,
0x6e,
0x2f);
// define ourselves cause mingw has these wrong
bool check_four(const char inA[4], const char inB[4])
{
return (*(uint32_t *) inA == *(uint32_t *) inB);
}
char *grab_next_camera_id(char *buffer, size_t bsz)
{
static size_t gotten = 0;
IMFAttributes *pAttributes = NULL;
IMFActivate **ppDevices = NULL;
buffer[0] = '\0';
HRESULT hr = MFCreateAttributes(&pAttributes, 1);
if (FAILED(hr)) {
log_info("MFCreateAttributes failed: %ld", hr);
goto done;
}
hr = pAttributes->lpVtbl->SetGUID(
pAttributes,
&MY_MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE,
&MY_MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID);
if (FAILED(hr)) {
log_info("SetGUID failed: %ld", hr);
goto done;
}
UINT32 count;
hr = MFEnumDeviceSources(pAttributes, &ppDevices, &count);
if (FAILED(hr)) {
log_info("MFEnumDeviceSources failed: %ld", hr);
goto done;
}
if (count <= gotten) {
log_info("gotten failed: %d < %d", count, (int) gotten);
// not enough remaining
goto done;
}
wchar_t wSymLink[CAMERA_DATA_STRING_SIZE];
UINT32 sz;
hr = ppDevices[gotten]->lpVtbl->GetString(
ppDevices[gotten],
&MY_MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINK,
wSymLink,
CAMERA_DATA_STRING_SIZE,
&sz);
if (FAILED(hr)) {
log_info("GetString failed: %ld", hr);
goto done;
}
wcstombs(buffer, wSymLink, bsz);
log_info("Detected webcam: %s\n", buffer);
++gotten;
done:
if (pAttributes) {
pAttributes->lpVtbl->Release(pAttributes);
}
for (DWORD i = 0; i < count; i++) {
if (ppDevices != NULL && ppDevices[i]) {
ppDevices[i]->lpVtbl->Release(ppDevices[i]);
}
}
CoTaskMemFree(ppDevices);
return buffer;
}
bool convert_sym_to_path(const char *sym, char *path)
{
HDEVINFO DeviceInfoSet = SetupDiCreateDeviceInfoList(NULL, NULL);
if (DeviceInfoSet == INVALID_HANDLE_VALUE) {
log_info("Could not open SetupDiCreateDeviceInfoList\n");
return 0;
}
SP_DEVICE_INTERFACE_DATA DeviceInterfaceData = {0};
DeviceInterfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
if (!SetupDiOpenDeviceInterfaceA(
DeviceInfoSet, sym, 0, &DeviceInterfaceData)) {
log_info("Could not SetupDiOpenDeviceInterfaceA\n");
return 0;
}
SP_DEVINFO_DATA DeviceInfoData = {0};
DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
if (!SetupDiGetDeviceInterfaceDetailA(
DeviceInfoSet,
&DeviceInterfaceData,
NULL,
0,
NULL,
&DeviceInfoData)) {
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
log_info("Could not SetupDiGetDeviceInterfaceDetailA\n");
return 0;
}
}
DWORD sz;
if (!SetupDiGetDeviceInstanceIdA(
DeviceInfoSet,
&DeviceInfoData,
path,
CAMERA_DATA_STRING_SIZE,
&sz)) {
log_info("Could not SetupDiGetDeviceInstanceIdA\n");
return 0;
}
if (DeviceInfoSet != INVALID_HANDLE_VALUE) {
if (!SetupDiDeleteDeviceInterfaceData(
DeviceInfoSet, &DeviceInterfaceData)) {
log_info("Could not SetupDiDeleteDeviceInterfaceData\n");
return 0;
}
SetupDiDestroyDeviceInfoList(DeviceInfoSet);
}
return 1;
}
void strtolower(char *str)
{
for (size_t i = 0; str[i]; i++) {
str[i] = tolower(str[i]);
}
}
bool convert_path_to_fakesym(const char *path, wchar_t *sym, char *extra_o)
{
char root[16] = {0};
char vidstr[16] = {0};
char pidstr[16] = {0};
char mistr[16] = {0};
char extra[64] = {0};
sscanf(
path,
"%[^\\]\\%[^&]&%[^&]&%[^\\]\\%s",
root,
vidstr,
pidstr,
mistr,
extra);
strcpy(extra_o, extra);
strtolower(root);
strtolower(vidstr);
strtolower(pidstr);
strtolower(mistr);
strtolower(extra);
char buffer[CAMERA_DATA_STRING_SIZE];
snprintf(
buffer,
CAMERA_DATA_STRING_SIZE,
"\\\\?\\%s#%s&%s&%s#%s",
root,
vidstr,
pidstr,
mistr,
extra);
mbstowcs(sym, buffer, CAMERA_DATA_STRING_SIZE);
return true;
}
void fill_cam_struct(struct camera_data *data, const char *devid)
{
char buffer[CAMERA_DATA_STRING_SIZE];
data->setup = false;
if (!devid || strlen(devid) == 0) {
devid = grab_next_camera_id(buffer, CAMERA_DATA_STRING_SIZE);
}
if (!devid || strlen(devid) == 0) {
// no more cameras remain?
return;
}
if (strlen(devid) >= CAMERA_DATA_STRING_SIZE) {
// error probably log something?
return;
}
// detect input type
if (check_four(devid, "\\\\?\\")) {
// SYMBOLIC_LINK
if (!convert_sym_to_path(devid, data->deviceInstancePath)) {
log_info("Could not convert %s to path", devid);
return;
}
} else if (check_four(devid, "USB\\")) {
// Device instance path
strcpy(data->deviceInstancePath, devid);
// continue
} else {
// UNKNOWN ENTRY
log_info("UNK: %s", devid);
log_info("Please enter the device instance path");
return;
}
if (!convert_path_to_fakesym(
data->deviceInstancePath,
data->deviceSymbolicLink,
data->extra_upper)) {
log_info("Could not convert %s to sym", data->deviceInstancePath);
return;
}
log_info("dev path: %s", data->deviceInstancePath);
char* vid_str = strstr(data->deviceInstancePath, "VID_");
char* pid_str = strstr(data->deviceInstancePath, "PID_");
if (!vid_str || !pid_str) {
log_info("Could not parse VID/PID in %s", data->deviceInstancePath);
return;
}
data->vid = strtol(vid_str + 4, NULL, 16);
data->pid = strtol(pid_str + 4, NULL, 16);
log_info("vid: %04x", data->vid);
log_info("pid: %04x", data->pid);
// locate device nodes
DEVINST dnDevInst;
DEVINST parentDev;
CONFIGRET cmret;
cmret = CM_Locate_DevNodeA(
&dnDevInst, data->deviceInstancePath, CM_LOCATE_DEVNODE_NORMAL);
if (cmret != CR_SUCCESS) {
log_info("CM_Locate_DevNodeA fail: %s", data->deviceInstancePath);
return;
}
cmret = CM_Get_Parent(&parentDev, dnDevInst, 0);
if (cmret != CR_SUCCESS) {
log_info("CM_Get_Parent fail: %s", data->deviceInstancePath);
return;
}
cmret = CM_Get_Device_IDA(
parentDev, data->parent_deviceInstancePath, CAMERA_DATA_STRING_SIZE, 0);
if (cmret != CR_SUCCESS) {
log_info("CM_Get_Device_IDA parent fail: %s", data->deviceInstancePath);
return;
}
ULONG szAddr;
ULONG szDesc;
ULONG szDriverKey;
szAddr = 4;
cmret = CM_Get_DevNode_Registry_PropertyA(
dnDevInst, CM_DRP_ADDRESS, NULL, &data->address, &szAddr, 0);
if (cmret != CR_SUCCESS) {
log_info(
"CM_Get_DevNode_Registry_PropertyA CM_DRP_ADDRESS fail: %s",
data->deviceInstancePath);
return;
}
szDesc = CAMERA_DATA_STRING_SIZE;
cmret = CM_Get_DevNode_Registry_PropertyA(
dnDevInst, CM_DRP_DEVICEDESC, NULL, &data->name, &szDesc, 0);
if (cmret != CR_SUCCESS) {
log_info(
"CM_Get_DevNode_Registry_PropertyA CM_DRP_DEVICEDESC fail: %s",
data->deviceInstancePath);
return;
}
szAddr = 4;
cmret = CM_Get_DevNode_Registry_PropertyA(
parentDev, CM_DRP_ADDRESS, NULL, &data->parent_address, &szAddr, 0);
if (cmret != CR_SUCCESS) {
log_info(
"CM_Get_DevNode_Registry_PropertyA CM_DRP_ADDRESS parent fail: %s",
data->deviceInstancePath);
return;
}
szDesc = CAMERA_DATA_STRING_SIZE;
cmret = CM_Get_DevNode_Registry_PropertyA(
parentDev, CM_DRP_DEVICEDESC, NULL, &data->parent_name, &szDesc, 0);
if (cmret != CR_SUCCESS) {
log_info(
"CM_Get_DevNode_Registry_PropertyA CM_DRP_DEVICEDESC parent fail: %s",
data->deviceInstancePath);
return;
}
szDriverKey = CAMERA_DATA_STRING_SIZE;
cmret = CM_Get_DevNode_Registry_PropertyA(
parentDev, CM_DRP_DRIVER, NULL, &data->parent_driverKey, &szDriverKey, 0);
if (cmret != CR_SUCCESS) {
log_info(
"CM_Get_DevNode_Registry_PropertyA CM_DRP_DRIVER parent fail: %s",
data->deviceInstancePath);
return;
}
log_info("Found %s @ %d", data->name, data->address);
log_info("Parent %s @ %d %s", data->parent_name, data->parent_address, data->parent_driverKey);
data->setup = true;
}

View File

@@ -0,0 +1,34 @@
#ifndef CAMHOOK_CAM_DETECT_H
#define CAMHOOK_CAM_DETECT_H
#include <stdbool.h>
#include <stdint.h>
#include <wchar.h>
#define CAMERA_DATA_STRING_SIZE 0x100
struct camera_data {
bool setup;
char name[CAMERA_DATA_STRING_SIZE];
char deviceInstancePath[CAMERA_DATA_STRING_SIZE];
wchar_t deviceSymbolicLink[CAMERA_DATA_STRING_SIZE];
char extra_upper[CAMERA_DATA_STRING_SIZE];
int address;
char parent_name[CAMERA_DATA_STRING_SIZE];
char parent_driverKey[CAMERA_DATA_STRING_SIZE];
char parent_deviceInstancePath[CAMERA_DATA_STRING_SIZE];
int parent_address;
int16_t vid;
int16_t pid;
bool fake_addressed;
int fake_address;
bool fake_located;
size_t fake_located_node;
};
void fill_cam_struct(struct camera_data *data, const char *devid);
#endif

View File

@@ -4,6 +4,8 @@
// Don't format because the order is important here // Don't format because the order is important here
#include <windows.h> #include <windows.h>
#include <initguid.h> #include <initguid.h>
#include <winioctl.h>
#include <usbioctl.h>
// clang-format on // clang-format on
#include <mfapi.h> #include <mfapi.h>
@@ -19,80 +21,25 @@
#include "hook/table.h" #include "hook/table.h"
#include "camhook/cam.h" #include "camhook/cam.h"
#include "camhook/cam-detect.h"
#include "util/defs.h" #include "util/defs.h"
#include "util/log.h" #include "util/log.h"
#include "util/str.h" #include "util/str.h"
#include "util/time.h"
#define CAMERA_DATA_STRING_SIZE 0x100 #define CAMHOOK_NUM_LAYOUTS 3
EXTERN_GUID( static struct camera_data camData[CAMHOOK_CONFIG_CAM_MAX];
MY_MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE, int camAddresses[CAMHOOK_NUM_LAYOUTS][CAMHOOK_CONFIG_CAM_MAX] = {
0xc60ac5fe, {1, 7},
0x252a, {4, 9},
0x478f, {4, 3},
0xa0,
0xef,
0xbc,
0x8f,
0xa5,
0xf7,
0xca,
0xd3);
EXTERN_GUID(
MY_MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID,
0x8ac3587a,
0x4ae7,
0x42d8,
0x99,
0xe0,
0x0a,
0x60,
0x13,
0xee,
0xf9,
0x0f);
EXTERN_GUID(
MY_MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINK,
0x58f0aad8,
0x22bf,
0x4f8a,
0xbb,
0x3d,
0xd2,
0xc4,
0x97,
0x8c,
0x6e,
0x2f);
// define ourselves cause mingw has these wrong
struct CameraData {
bool setup;
char name[CAMERA_DATA_STRING_SIZE];
char deviceInstancePath[CAMERA_DATA_STRING_SIZE];
wchar_t deviceSymbolicLink[CAMERA_DATA_STRING_SIZE];
char extra_upper[CAMERA_DATA_STRING_SIZE];
int address;
char parent_name[CAMERA_DATA_STRING_SIZE];
char parent_deviceInstancePath[CAMERA_DATA_STRING_SIZE];
int parent_address;
bool fake_addressed;
int fake_address;
bool fake_located;
size_t fake_located_node;
};
static struct CameraData camData[CAMHOOK_CONFIG_CAM_MAX];
int camAddresses[CAMHOOK_CONFIG_CAM_MAX] = {
1,
7,
}; };
static size_t num_addressed_cams = 0; static size_t num_addressed_cams = 0;
static size_t num_located_cams = 0; static size_t num_located_cams = 0;
static int camhook_port_layout = 0;
static enum camhook_version camhook_version = CAMHOOK_VERSION_OLD;
static CONFIGRET my_CM_Locate_DevNodeA( static CONFIGRET my_CM_Locate_DevNodeA(
PDEVINST pdnDevInst, DEVINSTID_A pDeviceID, ULONG ulFlags); PDEVINST pdnDevInst, DEVINSTID_A pDeviceID, ULONG ulFlags);
@@ -156,6 +103,26 @@ static HDEVINFO my_SetupDiGetClassDevsA(
static HDEVINFO (*real_SetupDiGetClassDevsA)( static HDEVINFO (*real_SetupDiGetClassDevsA)(
CONST GUID *ClassGuid, PCSTR Enumerator, HWND hwndParent, DWORD Flags); CONST GUID *ClassGuid, PCSTR Enumerator, HWND hwndParent, DWORD Flags);
static BOOL STDCALL my_DeviceIoControl(
HANDLE hFile,
uint32_t dwIoControlCode,
void *lpInBuffer,
uint32_t nInBufferSize,
void *lpOutBuffer,
uint32_t nOutBufferSize,
uint32_t *lpBytesReturned,
OVERLAPPED *lpOverlapped);
static BOOL(STDCALL *real_DeviceIoControl)(
HANDLE fd,
uint32_t code,
void *in_bytes,
uint32_t in_nbytes,
void *out_bytes,
uint32_t out_nbytes,
uint32_t *out_returned,
OVERLAPPED *ovl);
static const struct hook_symbol camhook_cfgmgr32_syms[] = { static const struct hook_symbol camhook_cfgmgr32_syms[] = {
{.name = "CM_Locate_DevNodeA", {.name = "CM_Locate_DevNodeA",
.patch = my_CM_Locate_DevNodeA, .patch = my_CM_Locate_DevNodeA,
@@ -180,12 +147,24 @@ static const struct hook_symbol camhook_cfgmgr32_syms[] = {
.link = (void **) &real_SetupDiGetClassDevsA}, .link = (void **) &real_SetupDiGetClassDevsA},
}; };
static const struct hook_symbol camhook_cfgmgr32_syms_new[] = {
{.name = "CM_Locate_DevNodeA",
.patch = my_CM_Locate_DevNodeA,
.link = (void **) &real_CM_Locate_DevNodeA},
};
static const struct hook_symbol camhook_mf_syms[] = { static const struct hook_symbol camhook_mf_syms[] = {
{.name = "MFEnumDeviceSources", {.name = "MFEnumDeviceSources",
.patch = my_MFEnumDeviceSources, .patch = my_MFEnumDeviceSources,
.link = (void **) &real_MFEnumDeviceSources}, .link = (void **) &real_MFEnumDeviceSources},
}; };
static struct hook_symbol camhook_ioctl_syms[] = {
{.name = "DeviceIoControl",
.patch = my_DeviceIoControl,
.link = (void *) &real_DeviceIoControl},
};
DEVINST camhook_custom_nodes[CAMHOOK_CONFIG_CAM_MAX] = { DEVINST camhook_custom_nodes[CAMHOOK_CONFIG_CAM_MAX] = {
0x04040004, 0x04040004,
0x04040008, 0x04040008,
@@ -209,25 +188,42 @@ my_CM_Locate_DevNodeA(PDEVINST pdnDevInst, DEVINSTID_A pDeviceID, ULONG ulFlags)
log_info("seeking: %s", pDeviceID); log_info("seeking: %s", pDeviceID);
for (size_t i = 0; i < CAMHOOK_CONFIG_CAM_MAX; ++i) { for (size_t i = 0; i < CAMHOOK_CONFIG_CAM_MAX; ++i) {
if (camData[i].setup) { if (camData[i].setup) {
snprintf( if (camhook_version == CAMHOOK_VERSION_OLD) {
builtString, snprintf(
CAMERA_DATA_STRING_SIZE, builtString,
"USB\\VID_288C&PID_0002&MI_00\\%s", CAMERA_DATA_STRING_SIZE,
camData[i].extra_upper); "USB\\VID_288C&PID_0002&MI_00\\%s",
camData[i].extra_upper);
} else if (camhook_version == CAMHOOK_VERSION_NEW) {
snprintf(
builtString,
CAMERA_DATA_STRING_SIZE,
"USB\\VID_05A3&PID_9230&MI_00\\%s",
camData[i].extra_upper);
}
log_info("built: %s", builtString); log_info("built: %s", builtString);
if (strcmp(pDeviceID, builtString) == 0) { if (strcmp(pDeviceID, builtString) == 0) {
if (!camData[i].fake_located) { if (camhook_version == CAMHOOK_VERSION_OLD) {
camData[i].fake_located_node = num_located_cams; if (!camData[i].fake_located) {
camData[i].fake_located = true; camData[i].fake_located_node = num_located_cams;
++num_located_cams; camData[i].fake_located = true;
++num_located_cams;
}
log_info(
"Injecting custom device %d to node %x",
(int) i,
(int) camData[i].fake_located_node);
*pdnDevInst =
camhook_custom_nodes[camData[i].fake_located_node];
return CR_SUCCESS;
} else if (camhook_version == CAMHOOK_VERSION_NEW) {
// inject original device
log_info(
"Injecting original device %d %s -> %s",
(int) i, pDeviceID, camData[i].deviceInstancePath);
pDeviceID = camData[i].deviceInstancePath;
} }
log_info(
"Injecting custom device %d to node %x",
(int) i,
(int) camData[i].fake_located_node);
*pdnDevInst =
camhook_custom_nodes[camData[i].fake_located_node];
return CR_SUCCESS;
} }
} }
} }
@@ -278,9 +274,9 @@ HRESULT my_GetAllocatedString(
IMFActivate *self, REFGUID guidKey, LPWSTR *ppwszValue, UINT32 *pcchLength) IMFActivate *self, REFGUID guidKey, LPWSTR *ppwszValue, UINT32 *pcchLength)
{ {
HRESULT ret; HRESULT ret;
log_info("Inside: %s", __FUNCTION__); // log_info("Inside: %s", __FUNCTION__);
// should probably check GUID, oh well // should probably check GUID == MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINK, oh well
ret = real_GetAllocatedString(self, guidKey, ppwszValue, pcchLength); ret = real_GetAllocatedString(self, guidKey, ppwszValue, pcchLength);
char *pMBBuffer = (char *) malloc(0x100); char *pMBBuffer = (char *) malloc(0x100);
wcstombs(pMBBuffer, *ppwszValue, 0x100); wcstombs(pMBBuffer, *ppwszValue, 0x100);
@@ -299,19 +295,35 @@ HRESULT my_GetAllocatedString(
// if matches, replace with target device ID // if matches, replace with target device ID
if (pwc) { if (pwc) {
// \\?\usb#vid_288c&pid_0002&mi_00 if (camhook_version == CAMHOOK_VERSION_OLD) {
pwc[12] = L'2'; // \\?\usb#vid_288c&pid_0002&mi_00
pwc[13] = L'8'; pwc[12] = L'2';
pwc[14] = L'8'; pwc[13] = L'8';
pwc[15] = L'c'; pwc[14] = L'8';
pwc[15] = L'c';
pwc[21] = L'0'; pwc[21] = L'0';
pwc[22] = L'0'; pwc[22] = L'0';
pwc[23] = L'0'; pwc[23] = L'0';
pwc[24] = L'2'; pwc[24] = L'2';
pwc[29] = L'0'; pwc[29] = L'0';
pwc[30] = L'0'; pwc[30] = L'0';
} else if (camhook_version == CAMHOOK_VERSION_NEW) {
// \\?\usb#vid_05a3&pid_9230&mi_00
pwc[12] = L'0';
pwc[13] = L'5';
pwc[14] = L'a';
pwc[15] = L'3';
pwc[21] = L'9';
pwc[22] = L'2';
pwc[23] = L'3';
pwc[24] = L'0';
pwc[29] = L'0';
pwc[30] = L'0';
}
wcstombs(pMBBuffer, *ppwszValue, 0x100); wcstombs(pMBBuffer, *ppwszValue, 0x100);
log_info("Replaced: %s", pMBBuffer); log_info("Replaced: %s", pMBBuffer);
@@ -334,7 +346,7 @@ static HRESULT my_MFEnumDeviceSources(
HRESULT ret; HRESULT ret;
log_info("Inside: %s", __FUNCTION__); // log_info("Inside: %s", __FUNCTION__);
ret = real_MFEnumDeviceSources( ret = real_MFEnumDeviceSources(
pAttributes, pppSourceActivate, pcSourceActivate); pAttributes, pppSourceActivate, pcSourceActivate);
nsrcs = *pcSourceActivate; nsrcs = *pcSourceActivate;
@@ -437,8 +449,9 @@ static BOOL my_SetupDiGetDeviceRegistryPropertyA(
if (camData[i].setup) { if (camData[i].setup) {
if (addr == camData[i].parent_address) { if (addr == camData[i].parent_address) {
if (!camData[i].fake_addressed) { if (!camData[i].fake_addressed) {
// old style always uses set 0
camData[i].fake_address = camData[i].fake_address =
camAddresses[num_addressed_cams]; camAddresses[0][num_addressed_cams];
camData[i].fake_addressed = true; camData[i].fake_addressed = true;
++num_addressed_cams; ++num_addressed_cams;
} }
@@ -491,315 +504,180 @@ static HDEVINFO my_SetupDiGetClassDevsA(
return real_SetupDiGetClassDevsA(ClassGuid, Enumerator, hwndParent, Flags); return real_SetupDiGetClassDevsA(ClassGuid, Enumerator, hwndParent, Flags);
} }
bool check_four(const char inA[4], const char inB[4]) ULONG get_matching_device_replacement_id(
HANDLE hFile,
ULONG ConnectionIndex,
USB_DEVICE_DESCRIPTOR* desc)
{ {
return (*(uint32_t *) inA == *(uint32_t *) inB); ULONG replacement_id = 0;
} for (size_t i = 0; i < CAMHOOK_CONFIG_CAM_MAX; ++i) {
if (camData[i].setup) {
// log_info("Checking %lu %04x %04x vs %lu %04x %04x",
// ConnectionIndex, desc->idVendor, desc->idProduct,
// camData[i].address, camData[i].vid, camData[i].pid);
if (
ConnectionIndex == camData[i].parent_address &&
desc->idVendor == camData[i].vid &&
desc->idProduct == camData[i].pid
) {
// do secondary check for driver key using
// IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME
USB_NODE_CONNECTION_DRIVERKEY_NAME req;
req.ActualLength = 0;
req.ConnectionIndex = ConnectionIndex;
req.DriverKeyName[0] = '\0';
char *grab_next_camera_id(char *buffer, size_t bsz) DWORD nBytes;
{
static size_t gotten = 0;
IMFAttributes *pAttributes = NULL; if (!DeviceIoControl(
IMFActivate **ppDevices = NULL; hFile,
IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME,
&req,
sizeof(req),
&req,
sizeof(req),
&nBytes,
0LL
)) {
log_warning(
"Failed to get driver key name size for device %04x %04x",
desc->idVendor,
desc->idProduct);
continue;
}
buffer[0] = '\0'; if (req.ActualLength <= sizeof(req)) {
log_warning(
"Driver key name size too small for device %04x %04x",
desc->idVendor,
desc->idProduct);
continue;
}
HRESULT hr = MFCreateAttributes(&pAttributes, 1); nBytes = req.ActualLength;
if (FAILED(hr)) { USB_NODE_CONNECTION_DRIVERKEY_NAME *driverKeyNameW = malloc(nBytes);
log_info("MFCreateAttributes failed: %ld", hr); if (!driverKeyNameW) {
goto done; log_warning("Failed to allocate driver key name buffer for device %04x %04x",
} desc->idVendor,
desc->idProduct);
continue;
}
driverKeyNameW->ActualLength = 0;
driverKeyNameW->ConnectionIndex = ConnectionIndex;
driverKeyNameW->DriverKeyName[0] = '\0';
hr = pAttributes->lpVtbl->SetGUID( if (!DeviceIoControl(
pAttributes, hFile,
&MY_MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE, IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME,
&MY_MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID); driverKeyNameW,
if (FAILED(hr)) { nBytes,
log_info("SetGUID failed: %ld", hr); driverKeyNameW,
goto done; nBytes,
} &nBytes,
0LL
)) {
log_warning(
"Failed to get driver key name for device %04x %04x",
desc->idVendor,
desc->idProduct);
continue;
}
UINT32 count;
hr = MFEnumDeviceSources(pAttributes, &ppDevices, &count); char *driverKeyNameA = NULL;
wstr_narrow(driverKeyNameW->DriverKeyName, &driverKeyNameA);
if (FAILED(hr)) { free(driverKeyNameW);
log_info("MFEnumDeviceSources failed: %ld", hr);
goto done;
}
if (count <= gotten) {
log_info("gotten failed: %d < %d", count, (int) gotten);
// not enough remaining
goto done;
}
wchar_t wSymLink[CAMERA_DATA_STRING_SIZE]; if (strcmp(driverKeyNameA, camData[i].parent_driverKey) != 0) {
UINT32 sz; // log just in case?
log_info(
"Driver key name mismatch for device %04x %04x %s != %s",
desc->idVendor,
desc->idProduct,
driverKeyNameA,
camData[i].parent_driverKey);
if (driverKeyNameA) {
free(driverKeyNameA);
}
continue;
}
hr = ppDevices[gotten]->lpVtbl->GetString( log_info(
ppDevices[gotten], "Replacing device @ %lu with %d for %04x %04x %s",
&MY_MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINK, ConnectionIndex,
wSymLink, camAddresses[camhook_port_layout][i],
CAMERA_DATA_STRING_SIZE, desc->idVendor,
&sz); desc->idProduct,
driverKeyNameA);
if (FAILED(hr)) { if (driverKeyNameA) {
log_info("GetString failed: %ld", hr); free(driverKeyNameA);
goto done; }
}
wcstombs(buffer, wSymLink, bsz); replacement_id = camAddresses[camhook_port_layout][i];
log_info("Detected webcam: %s\n", buffer); break;
++gotten; }
done:
if (pAttributes) {
pAttributes->lpVtbl->Release(pAttributes);
}
for (DWORD i = 0; i < count; i++) {
if (ppDevices != NULL && ppDevices[i]) {
ppDevices[i]->lpVtbl->Release(ppDevices[i]);
} }
} }
CoTaskMemFree(ppDevices); return replacement_id;
return buffer;
} }
bool convert_sym_to_path(const char *sym, char *path) static BOOL STDCALL my_DeviceIoControl(
HANDLE hFile,
uint32_t dwIoControlCode,
void *lpInBuffer,
uint32_t nInBufferSize,
void *lpOutBuffer,
uint32_t nOutBufferSize,
uint32_t *lpBytesReturned,
OVERLAPPED *lpOverlapped)
{ {
HDEVINFO DeviceInfoSet = SetupDiCreateDeviceInfoList(NULL, NULL); BOOL res;
if (DeviceInfoSet == INVALID_HANDLE_VALUE) { res = real_DeviceIoControl(
log_info("Could not open SetupDiCreateDeviceInfoList\n"); hFile,
return 0; dwIoControlCode,
lpInBuffer,
nInBufferSize,
lpOutBuffer,
nOutBufferSize,
lpBytesReturned,
lpOverlapped);
// if error just return
if (!res) {
return res;
} }
SP_DEVICE_INTERFACE_DATA DeviceInterfaceData = {0}; // detect IOCTL_USB_GET_NODE_CONNECTION_INFORMATION (_EX)
DeviceInterfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA); // we don't bother faking the rest as it's never read
if (dwIoControlCode == IOCTL_USB_GET_NODE_CONNECTION_INFORMATION) {
USB_NODE_CONNECTION_INFORMATION *connectionInfo = lpOutBuffer;
if (!SetupDiOpenDeviceInterfaceA( ULONG replacement_id = get_matching_device_replacement_id(
DeviceInfoSet, sym, 0, &DeviceInterfaceData)) { hFile, connectionInfo->ConnectionIndex, &connectionInfo->DeviceDescriptor);
log_info("Could not SetupDiOpenDeviceInterfaceA\n"); if (replacement_id > 0) {
return 0; connectionInfo->ConnectionIndex = replacement_id;
} }
} else if (dwIoControlCode == IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX) {
USB_NODE_CONNECTION_INFORMATION_EX *connectionInfoEx = lpOutBuffer;
SP_DEVINFO_DATA DeviceInfoData = {0}; ULONG replacement_id = get_matching_device_replacement_id(
DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA); hFile, connectionInfoEx->ConnectionIndex, &connectionInfoEx->DeviceDescriptor);
if (replacement_id > 0) {
if (!SetupDiGetDeviceInterfaceDetailA( connectionInfoEx->ConnectionIndex = replacement_id;
DeviceInfoSet,
&DeviceInterfaceData,
NULL,
0,
NULL,
&DeviceInfoData)) {
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
log_info("Could not SetupDiGetDeviceInterfaceDetailA\n");
return 0;
} }
} }
DWORD sz; return res;
if (!SetupDiGetDeviceInstanceIdA(
DeviceInfoSet,
&DeviceInfoData,
path,
CAMERA_DATA_STRING_SIZE,
&sz)) {
log_info("Could not SetupDiGetDeviceInstanceIdA\n");
return 0;
}
if (DeviceInfoSet != INVALID_HANDLE_VALUE) {
if (!SetupDiDeleteDeviceInterfaceData(
DeviceInfoSet, &DeviceInterfaceData)) {
log_info("Could not SetupDiDeleteDeviceInterfaceData\n");
return 0;
}
SetupDiDestroyDeviceInfoList(DeviceInfoSet);
}
return 1;
} }
void strtolower(char *str) void camhook_set_version(enum camhook_version version) {
{ camhook_version = version;
for (size_t i = 0; str[i]; i++) {
str[i] = tolower(str[i]);
}
}
bool convert_path_to_fakesym(const char *path, wchar_t *sym, char *extra_o)
{
char root[16] = {0};
char vidstr[16] = {0};
char pidstr[16] = {0};
char mistr[16] = {0};
char extra[64] = {0};
sscanf(
path,
"%[^\\]\\%[^&]&%[^&]&%[^\\]\\%s",
root,
vidstr,
pidstr,
mistr,
extra);
strcpy(extra_o, extra);
strtolower(root);
strtolower(vidstr);
strtolower(pidstr);
strtolower(mistr);
strtolower(extra);
char buffer[CAMERA_DATA_STRING_SIZE];
snprintf(
buffer,
CAMERA_DATA_STRING_SIZE,
"\\\\?\\%s#%s&%s&%s#%s",
root,
vidstr,
pidstr,
mistr,
extra);
mbstowcs(sym, buffer, CAMERA_DATA_STRING_SIZE);
return true;
}
void fill_cam_struct(struct CameraData *data, const char *devid)
{
char buffer[CAMERA_DATA_STRING_SIZE];
data->setup = false;
if (!devid || strlen(devid) == 0) {
devid = grab_next_camera_id(buffer, CAMERA_DATA_STRING_SIZE);
}
if (!devid || strlen(devid) == 0) {
// no more cameras remain?
return;
}
if (strlen(devid) >= CAMERA_DATA_STRING_SIZE) {
// error probably log something?
return;
}
// detect input type
if (check_four(devid, "\\\\?\\")) {
// SYMBOLIC_LINK
if (!convert_sym_to_path(devid, data->deviceInstancePath)) {
log_info("Could not convert %s to path", devid);
return;
}
} else if (check_four(devid, "USB\\")) {
// Device instance path
strcpy(data->deviceInstancePath, devid);
// continue
} else {
// UNKNOWN ENTRY
log_info("UNK: %s", devid);
log_info("Please enter the device instance path");
return;
}
if (!convert_path_to_fakesym(
data->deviceInstancePath,
data->deviceSymbolicLink,
data->extra_upper)) {
log_info("Could not convert %s to sym", data->deviceInstancePath);
return;
}
log_info("dev path: %s", data->deviceInstancePath);
// locate device nodes
DEVINST dnDevInst;
DEVINST parentDev;
CONFIGRET cmret;
cmret = CM_Locate_DevNodeA(
&dnDevInst, data->deviceInstancePath, CM_LOCATE_DEVNODE_NORMAL);
if (cmret != CR_SUCCESS) {
log_info("CM_Locate_DevNodeA fail: %s", data->deviceInstancePath);
return;
}
cmret = CM_Get_Parent(&parentDev, dnDevInst, 0);
if (cmret != CR_SUCCESS) {
log_info("CM_Get_Parent fail: %s", data->deviceInstancePath);
return;
}
cmret = CM_Get_Device_IDA(
parentDev, data->parent_deviceInstancePath, CAMERA_DATA_STRING_SIZE, 0);
if (cmret != CR_SUCCESS) {
log_info("CM_Get_Device_IDA parent fail: %s", data->deviceInstancePath);
return;
}
ULONG szAddr;
ULONG szDesc;
szAddr = 4;
szDesc = CAMERA_DATA_STRING_SIZE;
cmret = CM_Get_DevNode_Registry_PropertyA(
dnDevInst, CM_DRP_ADDRESS, NULL, &data->address, &szAddr, 0);
if (cmret != CR_SUCCESS) {
log_info(
"CM_Get_DevNode_Registry_PropertyA fail: %s",
data->deviceInstancePath);
return;
}
cmret = CM_Get_DevNode_Registry_PropertyA(
dnDevInst, CM_DRP_DEVICEDESC, NULL, &data->name, &szDesc, 0);
if (cmret != CR_SUCCESS) {
log_info(
"CM_Get_DevNode_Registry_PropertyA fail: %s",
data->deviceInstancePath);
return;
}
szAddr = 4;
szDesc = CAMERA_DATA_STRING_SIZE;
cmret = CM_Get_DevNode_Registry_PropertyA(
parentDev, CM_DRP_ADDRESS, NULL, &data->parent_address, &szAddr, 0);
if (cmret != CR_SUCCESS) {
log_info(
"CM_Get_DevNode_Registry_PropertyA parent fail: %s",
data->deviceInstancePath);
return;
}
cmret = CM_Get_DevNode_Registry_PropertyA(
parentDev, CM_DRP_DEVICEDESC, NULL, &data->parent_name, &szDesc, 0);
if (cmret != CR_SUCCESS) {
log_info(
"CM_Get_DevNode_Registry_PropertyA parent fail: %s",
data->deviceInstancePath);
return;
}
log_info("Found %s @ %d", data->name, data->address);
log_info("Parent %s @ %d", data->parent_name, data->parent_address);
data->setup = true;
} }
void camhook_init(struct camhook_config_cam *config_cam) void camhook_init(struct camhook_config_cam *config_cam)
@@ -827,15 +705,42 @@ void camhook_init(struct camhook_config_cam *config_cam)
} }
} }
camhook_port_layout = config_cam->port_layout;
if (camhook_port_layout < 0 || camhook_port_layout >= CAMHOOK_NUM_LAYOUTS) {
camhook_port_layout = 0;
}
if (num_setup > 0) { if (num_setup > 0) {
hook_table_apply( // always
NULL,
"setupapi.dll",
camhook_cfgmgr32_syms,
lengthof(camhook_cfgmgr32_syms));
hook_table_apply( hook_table_apply(
NULL, "Mf.dll", camhook_mf_syms, lengthof(camhook_mf_syms)); NULL, "Mf.dll", camhook_mf_syms, lengthof(camhook_mf_syms));
if (camhook_version == CAMHOOK_VERSION_OLD) {
hook_table_apply(
NULL,
"cfgmgr32.dll",
camhook_cfgmgr32_syms,
lengthof(camhook_cfgmgr32_syms));
} else if (camhook_version == CAMHOOK_VERSION_NEW) {
// for CAMHOOK_VERSION_NEW we restore original VID/PID
// so the parent lookup succeeds later
// yes the DLL moved???
hook_table_apply(
NULL,
"setupapi.dll",
camhook_cfgmgr32_syms_new,
lengthof(camhook_cfgmgr32_syms_new));
// they copied / forked usb/usbview/enum.c
// however they don't use most of it
// so we only need DeviceIoControl to inject port #
hook_table_apply(
NULL,
"kernel32.dll",
camhook_ioctl_syms,
lengthof(camhook_ioctl_syms));
}
log_info("Inserted cam hooks for %d cams", (int) num_setup); log_info("Inserted cam hooks for %d cams", (int) num_setup);
// If the user has manually disabled all cams, don't print this in the // If the user has manually disabled all cams, don't print this in the
// log // log

View File

@@ -3,6 +3,15 @@
#include "camhook/config-cam.h" #include "camhook/config-cam.h"
// unused to control which camhook version is being used
// defaults to CAMHOOK_VERSION_OLD
enum camhook_version {
CAMHOOK_VERSION_OLD,
CAMHOOK_VERSION_NEW,
};
void camhook_set_version(enum camhook_version version);
void camhook_init(struct camhook_config_cam *config_cam); void camhook_init(struct camhook_config_cam *config_cam);
void camhook_fini(void); void camhook_fini(void);

View File

@@ -7,6 +7,9 @@
#define CAMHOOK_CONFIG_CAM_DISABLE_EMU_KEY "cam.disable_emu" #define CAMHOOK_CONFIG_CAM_DISABLE_EMU_KEY "cam.disable_emu"
#define CAMHOOK_CONFIG_CAM_DEFAULT_DISABLE_EMU_VALUE false #define CAMHOOK_CONFIG_CAM_DEFAULT_DISABLE_EMU_VALUE false
#define CAMHOOK_CONFIG_CAM_PORT_LAYOUT_KEY "cam.port_layout"
#define CAMHOOK_CONFIG_CAM_DEFAULT_PORT_LAYOUT_VALUE 0
// the following four arrays are based on CAMHOOK_CONFIG_CAM_MAX // the following four arrays are based on CAMHOOK_CONFIG_CAM_MAX
// please insert more elements if more cams are added // please insert more elements if more cams are added
const char *camhook_config_disable_camera[CAMHOOK_CONFIG_CAM_MAX] = { const char *camhook_config_disable_camera[CAMHOOK_CONFIG_CAM_MAX] = {
@@ -30,7 +33,7 @@ const char *camhook_config_device_default_values[CAMHOOK_CONFIG_CAM_MAX] = {
"", "",
}; };
void camhook_config_cam_init(struct cconfig *config, size_t num_cams) void camhook_config_cam_init(struct cconfig *config, size_t num_cams, bool use_port_layout)
{ {
cconfig_util_set_bool( cconfig_util_set_bool(
config, config,
@@ -38,6 +41,14 @@ void camhook_config_cam_init(struct cconfig *config, size_t num_cams)
CAMHOOK_CONFIG_CAM_DEFAULT_DISABLE_EMU_VALUE, CAMHOOK_CONFIG_CAM_DEFAULT_DISABLE_EMU_VALUE,
"Disables the camera emulation"); "Disables the camera emulation");
if (use_port_layout) {
cconfig_util_set_int(
config,
CAMHOOK_CONFIG_CAM_PORT_LAYOUT_KEY,
CAMHOOK_CONFIG_CAM_DEFAULT_PORT_LAYOUT_VALUE,
"Camera port layout (0 = LDJ, 1 = CLDJ/TDJ-JA, 2 = TDJ-JB)");
}
for (size_t i = 0; i < num_cams; ++i) { for (size_t i = 0; i < num_cams; ++i) {
cconfig_util_set_bool( cconfig_util_set_bool(
config, config,
@@ -56,7 +67,8 @@ void camhook_config_cam_init(struct cconfig *config, size_t num_cams)
void camhook_config_cam_get( void camhook_config_cam_get(
struct camhook_config_cam *config_cam, struct camhook_config_cam *config_cam,
struct cconfig *config, struct cconfig *config,
size_t num_cams) size_t num_cams,
bool use_port_layout)
{ {
config_cam->num_devices = num_cams; config_cam->num_devices = num_cams;
@@ -71,6 +83,21 @@ void camhook_config_cam_get(
CAMHOOK_CONFIG_CAM_DISABLE_EMU_KEY, CAMHOOK_CONFIG_CAM_DISABLE_EMU_KEY,
CAMHOOK_CONFIG_CAM_DEFAULT_DISABLE_EMU_VALUE); CAMHOOK_CONFIG_CAM_DEFAULT_DISABLE_EMU_VALUE);
} }
if (use_port_layout) {
if (!cconfig_util_get_int(
config,
CAMHOOK_CONFIG_CAM_PORT_LAYOUT_KEY,
&config_cam->port_layout,
CAMHOOK_CONFIG_CAM_DEFAULT_PORT_LAYOUT_VALUE)) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%d'",
CAMHOOK_CONFIG_CAM_PORT_LAYOUT_KEY,
CAMHOOK_CONFIG_CAM_DEFAULT_PORT_LAYOUT_VALUE);
}
}
for (size_t i = 0; i < num_cams; ++i) { for (size_t i = 0; i < num_cams; ++i) {
if (!cconfig_util_get_bool( if (!cconfig_util_get_bool(
config, config,

View File

@@ -10,15 +10,20 @@
struct camhook_config_cam { struct camhook_config_cam {
bool disable_emu; bool disable_emu;
size_t num_devices; size_t num_devices;
int port_layout;
char device_id[CAMHOOK_CONFIG_CAM_MAX][MAX_PATH]; char device_id[CAMHOOK_CONFIG_CAM_MAX][MAX_PATH];
bool disable_camera[CAMHOOK_CONFIG_CAM_MAX]; bool disable_camera[CAMHOOK_CONFIG_CAM_MAX];
}; };
void camhook_config_cam_init(struct cconfig *config, size_t num_cams); void camhook_config_cam_init(
struct cconfig *config,
size_t num_cams,
bool use_port_layout);
void camhook_config_cam_get( void camhook_config_cam_get(
struct camhook_config_cam *config_cam, struct camhook_config_cam *config_cam,
struct cconfig *config, struct cconfig *config,
size_t num_cams); size_t num_cams,
bool use_port_layout);
#endif #endif

View File

@@ -1,20 +0,0 @@
libs += core
libs_core := \
util \
src_core := \
log-bt-ext.c \
log-bt.c \
log-sink-async.c \
log-sink-debug.c \
log-sink-file.c \
log-sink-list.c \
log-sink-mutex.c \
log-sink-null.c \
log-sink-std.c \
log.c \
thread-crt-ext.c \
thread-crt.c \
thread.c \

View File

@@ -1,67 +0,0 @@
#include <stdbool.h>
#include "core/log-bt.h"
#include "core/log-sink-debug.h"
#include "core/log-sink-file.h"
#include "core/log-sink-list.h"
#include "core/log-sink-mutex.h"
#include "core/log-sink-std.h"
#include "core/log.h"
void core_log_bt_ext_impl_set()
{
core_log_impl_set(
core_log_bt_log_misc,
core_log_bt_log_info,
core_log_bt_log_warning,
core_log_bt_log_fatal);
}
void core_log_bt_ext_init_with_stdout()
{
struct core_log_sink sink;
core_log_sink_std_out_open(true, &sink);
core_log_bt_init(&sink);
}
void core_log_bt_ext_init_with_stderr()
{
struct core_log_sink sink;
core_log_sink_std_err_open(true, &sink);
core_log_bt_init(&sink);
}
void core_log_bt_ext_init_with_debug()
{
struct core_log_sink sink;
core_log_sink_debug_open(&sink);
core_log_bt_init(&sink);
}
void core_log_bt_ext_init_with_file(
const char *path, bool append, bool rotate, uint8_t max_rotations)
{
struct core_log_sink sink;
core_log_sink_file_open(path, append, rotate, max_rotations, &sink);
core_log_bt_init(&sink);
}
void core_log_bt_ext_init_with_stdout_and_file(
const char *path, bool append, bool rotate, uint8_t max_rotations)
{
struct core_log_sink sinks[2];
struct core_log_sink sink_composed;
struct core_log_sink sink_mutex;
core_log_sink_std_out_open(true, &sinks[0]);
core_log_sink_file_open(path, append, rotate, max_rotations, &sinks[1]);
core_log_sink_list_open(sinks, 2, &sink_composed);
core_log_sink_mutex_open(&sink_composed, &sink_mutex);
core_log_bt_init(&sink_mutex);
}

View File

@@ -1,59 +0,0 @@
#ifndef CORE_LOG_BT_EXT_H
#define CORE_LOG_BT_EXT_H
#include <stdbool.h>
#include <stdint.h>
/**
* Set the current thread API implementation to use the bemanitools log
* implementation
*/
void core_log_bt_ext_impl_set();
/**
* Helper to setup the bemanitools log implementation with a stdout sink.
*/
void core_log_bt_ext_init_with_stdout();
/**
* Helper to setup the bemanitools log implementation with a stderr sink.
*/
void core_log_bt_ext_init_with_stderr();
/**
* Helper to setup the bemanitools log implementation with a OutputDebugStr
* sink.
*/
void core_log_bt_ext_init_with_debug();
/**
* Helper to setup the bemanitools log implementation with a file sink
*
* @param path Path to the log file to write the log output to
* @param append If true, then append to an existing file, false to overwrite
* any existing file
* @param rotate If true, rotates an existing log file and creates a new one
* for this session
* @param max_rotations Max number of rotations for the log files
*/
void core_log_bt_ext_init_with_file(
const char *path, bool append, bool rotate, uint8_t max_rotations);
/**
* Helper to setup the bemanitools log implementation with a stdout and file
* sink
*
* Important: This combined sink is guarded by a mutex to avoid data races on
* logging to two different sinks.
*
* @param path Path to the log file to write the log output to
* @param append If true, then append to an existing file, false to overwrite
* any existing file
* @param rotate If true, rotates an existing log file and creates a new one
* for this session
* @param max_rotations Max number of rotations for the log files
*/
void core_log_bt_ext_init_with_stdout_and_file(
const char *path, bool append, bool rotate, uint8_t max_rotations);
#endif

View File

@@ -1,129 +0,0 @@
#include <stdarg.h>
#include <stdlib.h>
#include <time.h>
#include "core/log-bt.h"
#include "core/log-sink.h"
#include "core/log.h"
#include "util/mem.h"
#include "util/str.h"
static enum core_log_bt_log_level _core_log_bt_log_level;
static struct core_log_sink *_core_log_bt_sink;
static void _core_log_bt_vformat_write(
enum core_log_bt_log_level level,
const char *module,
const char *fmt,
va_list ap)
{
static const char chars[] = "FFWIM";
char timestamp[64];
/* 64k so we can log data dumps of rs232 without crashing */
char msg[65536];
char line[65536];
int result;
time_t curtime;
struct tm *tm;
curtime = 0;
tm = NULL;
curtime = time(NULL);
tm = localtime(&curtime);
strftime(timestamp, sizeof(timestamp), "[%Y/%m/%d %H:%M:%S]", tm);
str_vformat(msg, sizeof(msg), fmt, ap);
result = str_format(
line,
sizeof(line),
"%s %c:%s: %s\n",
timestamp,
chars[level],
module,
msg);
_core_log_bt_sink->write(_core_log_bt_sink->ctx, line, result);
}
void core_log_bt_init(const struct core_log_sink *sink)
{
if (sink == NULL) {
abort();
}
_core_log_bt_sink = xmalloc(sizeof(struct core_log_sink));
memcpy(_core_log_bt_sink, sink, sizeof(struct core_log_sink));
_core_log_bt_log_level = CORE_LOG_BT_LOG_LEVEL_OFF;
}
void core_log_bt_level_set(enum core_log_bt_log_level level)
{
_core_log_bt_log_level = level;
}
void core_log_bt_fini()
{
log_assert(_core_log_bt_sink);
_core_log_bt_sink->close(_core_log_bt_sink->ctx);
free(_core_log_bt_sink);
}
void core_log_bt_log_fatal(const char *module, const char *fmt, ...)
{
va_list ap;
if (_core_log_bt_log_level >= CORE_LOG_BT_LOG_LEVEL_FATAL) {
va_start(ap, fmt);
_core_log_bt_vformat_write(
CORE_LOG_BT_LOG_LEVEL_FATAL, module, fmt, ap);
va_end(ap);
}
}
void core_log_bt_log_warning(const char *module, const char *fmt, ...)
{
va_list ap;
if (_core_log_bt_log_level >= CORE_LOG_BT_LOG_LEVEL_WARNING) {
va_start(ap, fmt);
_core_log_bt_vformat_write(
CORE_LOG_BT_LOG_LEVEL_WARNING, module, fmt, ap);
va_end(ap);
}
}
void core_log_bt_log_info(const char *module, const char *fmt, ...)
{
va_list ap;
if (_core_log_bt_log_level >= CORE_LOG_BT_LOG_LEVEL_INFO) {
va_start(ap, fmt);
_core_log_bt_vformat_write(CORE_LOG_BT_LOG_LEVEL_INFO, module, fmt, ap);
va_end(ap);
}
}
void core_log_bt_log_misc(const char *module, const char *fmt, ...)
{
va_list ap;
if (_core_log_bt_log_level >= CORE_LOG_BT_LOG_LEVEL_MISC) {
va_start(ap, fmt);
_core_log_bt_vformat_write(CORE_LOG_BT_LOG_LEVEL_MISC, module, fmt, ap);
va_end(ap);
}
}
void core_log_bt_direct_sink_write(const char *chars, size_t nchars)
{
_core_log_bt_sink->write(_core_log_bt_sink->ctx, chars, nchars);
}

View File

@@ -1,87 +0,0 @@
#ifndef CORE_LOG_BT_H
#define CORE_LOG_BT_H
#include "core/log-sink.h"
/**
* Log API implementation for games/applications without AVS
*/
enum core_log_bt_log_level {
CORE_LOG_BT_LOG_LEVEL_OFF = 0,
CORE_LOG_BT_LOG_LEVEL_FATAL = 1,
CORE_LOG_BT_LOG_LEVEL_WARNING = 2,
CORE_LOG_BT_LOG_LEVEL_INFO = 3,
CORE_LOG_BT_LOG_LEVEL_MISC = 4,
};
/**
* Initialize the logging backend
*
* This must be called as early as possible in your application to setup
* a logging sink according to your needs. Until this is finished, no
* log output is available.
*
* By default, logging is turned off entirely and must be enabled by setting
* a desired logging level explicitly.
*
* @param sink Pointer to a log sink implementation. The caller owns the memory
* of this.
*/
void core_log_bt_init(const struct core_log_sink *sink);
/**
* Set the current logging level. This can be changed at any given time, e.g.
* to increase/decrease verbosity.
*
* @param level The logging level to set.
*/
void core_log_bt_level_set(enum core_log_bt_log_level level);
/**
* Cleanup the logging backend.
*
* Ensure to call this on application exit and cleanup.
*/
void core_log_bt_fini();
/**
* Implementation of the log API.
*/
void core_log_bt_log_fatal(const char *module, const char *fmt, ...);
/**
* Implementation of the log API.
*/
void core_log_bt_log_warning(const char *module, const char *fmt, ...);
/**
* Implementation of the log API.
*/
void core_log_bt_log_info(const char *module, const char *fmt, ...);
/**
* Implementation of the log API.
*/
void core_log_bt_log_misc(const char *module, const char *fmt, ...);
/**
* Allow AVS to by-pass the core log API/engine.
*
* This function must only be called by AVS in an appropriate log callback
* function that is passed to avs_boot.
*
* AVS has it's own logging engine and manages aspects such as async logging,
* log levels and decorating log messages.
*
* Thus, proper interoperability only requires the writer/sink part to be shared
* with AVS.
*
* @param chars Buffer with text data to write to the configured sinks. The
* buffer might contain several log messages separated by newline
* characters.
* @param nchars Number of chars to write to the sink.
*/
void core_log_bt_direct_sink_write(const char *chars, size_t nchars);
#endif

View File

@@ -1,23 +0,0 @@
#include <stdlib.h>
#include "core/log-sink.h"
static void
_core_log_sink_file_write(void *ctx, const char *chars, size_t nchars)
{
// TODO
}
static void _core_log_sink_file_close(void *ctx)
{
// TODO
}
void core_log_sink_async_open(struct core_log_sink *sink)
{
// TODO
sink->ctx = NULL;
sink->write = _core_log_sink_file_write;
sink->close = _core_log_sink_file_close;
}

View File

@@ -1,19 +0,0 @@
#ifndef CORE_LOG_SINK_ASYNC_H
#define CORE_LOG_SINK_ASYNC_H
#include <stdint.h>
#include <stdlib.h>
#include "core/log-sink.h"
/**
* Open a async log sink
*
* The sink passes data to log to a separate thread which executes the actual
* logging of the data.
*
* @param sink Pointer to allocated memory that receives the opened sink
*/
void core_log_sink_async_open(struct core_log_sink *sink);
#endif

View File

@@ -1,23 +0,0 @@
#include <debugapi.h>
#include <stdlib.h>
#include "core/log-sink.h"
static void
_core_log_sink_debug_write(void *ctx, const char *chars, size_t nchars)
{
OutputDebugStringA(chars);
}
static void _core_log_sink_debug_close(void *ctx)
{
// noop
}
void core_log_sink_debug_open(struct core_log_sink *sink)
{
sink->ctx = NULL;
sink->write = _core_log_sink_debug_write;
sink->close = _core_log_sink_debug_close;
}

View File

@@ -1,15 +0,0 @@
#ifndef CORE_LOG_SINK_DEBUG_H
#define CORE_LOG_SINK_DEBUG_H
#include <stdlib.h>
#include "core/log-sink.h"
/**
* Open a log sink that uses OutputDebugStr
*
* @param sink Pointer to allocated memory that receives the opened sink
*/
void core_log_sink_debug_open(struct core_log_sink *sink);
#endif

View File

@@ -1,92 +0,0 @@
#include <windows.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "core/log-sink.h"
#include "util/fs.h"
#include "util/str.h"
static void _core_log_sink_file_rotate(const char *path, uint8_t max_rotations)
{
uint8_t i;
char rotate_file[MAX_PATH];
char rotate_file_next[MAX_PATH];
char version[8];
char version_next[8];
for (i = max_rotations; i > 0; i++) {
str_cpy(rotate_file, sizeof(rotate_file), path);
str_cpy(rotate_file_next, sizeof(rotate_file_next), path);
if (i - 1 != 0) {
sprintf(version, ".%d", i);
} else {
memset(version, 0, sizeof(version));
}
sprintf(version_next, ".%d", i);
str_cat(rotate_file, sizeof(rotate_file), version);
str_cat(rotate_file_next, sizeof(rotate_file_next), version_next);
if (path_exists(rotate_file)) {
CopyFile(rotate_file, rotate_file_next, FALSE);
}
}
}
static void
_core_log_sink_file_write(void *ctx, const char *chars, size_t nchars)
{
FILE *file;
file = (FILE *) ctx;
fwrite(chars, 1, nchars, file);
}
static void _core_log_sink_file_close(void *ctx)
{
FILE *file;
file = (FILE *) ctx;
fflush(file);
fclose(file);
}
void core_log_sink_file_open(
const char *path,
bool append,
bool rotate,
uint8_t max_rotations,
struct core_log_sink *sink)
{
FILE *file;
if (rotate) {
_core_log_sink_file_rotate(path, max_rotations);
// Appending doesn't matter when file is rotated anyway
file = fopen(path, "w+");
} else {
if (append) {
file = fopen(path, "a+");
} else {
file = fopen(path, "w+");
}
}
if (!file) {
printf("Cannot open log file: %s", path);
abort();
}
sink->ctx = (void *) file;
sink->write = _core_log_sink_file_write;
sink->close = _core_log_sink_file_close;
}

View File

@@ -1,28 +0,0 @@
#ifndef CORE_LOG_SINK_FILE_H
#define CORE_LOG_SINK_FILE_H
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include "core/log-sink.h"
/**
* Open a log sink writing data to a file
*
* @param path Path to the log file to write the log output to
* @param append If true, then append to an existing file, false to overwrite
* any existing file
* @param rotate If true, rotates an existing log file and creates a new one
* for this session
* @param max_rotations Max number of rotations for the log files
* @param sink Pointer to allocated memory that receives the opened sink
*/
void core_log_sink_file_open(
const char *path,
bool append,
bool rotate,
uint8_t max_rotations,
struct core_log_sink *sink);
#endif

View File

@@ -1,66 +0,0 @@
#include <stdint.h>
#include <stdlib.h>
#include "core/log-sink-list.h"
#include "core/log-sink.h"
#include "util/mem.h"
#define MAX_SINKS 8
struct core_log_sink_list {
struct core_log_sink entries[MAX_SINKS];
uint8_t num;
};
static void
_core_log_sink_list_write(void *ctx, const char *chars, size_t nchars)
{
struct core_log_sink_list *sink_list;
int i;
sink_list = (struct core_log_sink_list *) ctx;
for (i = 0; i < sink_list->num; i++) {
sink_list->entries[i].write(sink_list->entries[i].ctx, chars, nchars);
}
}
static void _core_log_sink_list_close(void *ctx)
{
struct core_log_sink_list *sink_list;
int i;
sink_list = (struct core_log_sink_list *) ctx;
for (i = 0; i < sink_list->num; i++) {
sink_list->entries[i].close(sink_list->entries[i].ctx);
}
free(sink_list);
}
void core_log_sink_list_open(
const struct core_log_sink *entry, uint8_t num, struct core_log_sink *sink)
{
struct core_log_sink_list *sink_list;
int i;
if (num > MAX_SINKS) {
abort();
}
sink_list = xmalloc(sizeof(struct core_log_sink_list));
for (i = 0; i < num; i++) {
sink_list->entries[i].ctx = entry[i].ctx;
sink_list->entries[i].write = entry[i].write;
sink_list->entries[i].close = entry[i].close;
}
sink_list->num = num;
sink->ctx = (void *) sink_list;
sink->write = _core_log_sink_list_write;
sink->close = _core_log_sink_list_close;
}

View File

@@ -1,24 +0,0 @@
#ifndef CORE_LOG_SINK_LIST_H
#define CORE_LOG_SINK_LIST_H
#include <stdint.h>
#include <stdlib.h>
#include "core/log-sink.h"
/**
* Combine multiple log sinks into a list of sinks.
*
* Upon invoking a list sink, all sinks contained within the list are
* being invoked in the configured order.
*
* @param entry A pointer to allocated memory with a sequence of opened sinks
* that you want to add to the list. Ownership of these sinks
* is transferred, i.e. closing the list sink closes its children.
* @param num The number of elements in the sequence of opened sinks pointed to.
* @param sink Pointer to allocated memory that receives the opened sink
*/
void core_log_sink_list_open(
const struct core_log_sink *entry, uint8_t num, struct core_log_sink *sink);
#endif

View File

@@ -1,53 +0,0 @@
#include <windows.h>
#include <stdlib.h>
#include "core/log-sink.h"
#include "util/mem.h"
struct core_log_sink_mutex_ctx {
struct core_log_sink *child;
HANDLE mutex;
};
static void
_core_log_sink_mutex_write(void *ctx_, const char *chars, size_t nchars)
{
struct core_log_sink_mutex_ctx *ctx;
ctx = (struct core_log_sink_mutex_ctx *) ctx_;
WaitForSingleObject(ctx->mutex, INFINITE);
ctx->child->write(ctx->child->ctx, chars, nchars);
ReleaseMutex(ctx->mutex);
}
static void _core_log_sink_mutex_close(void *ctx_)
{
struct core_log_sink_mutex_ctx *ctx;
ctx = (struct core_log_sink_mutex_ctx *) ctx_;
CloseHandle(ctx->mutex);
ctx->child->close(ctx->child->ctx);
free(ctx);
}
void core_log_sink_mutex_open(
const struct core_log_sink *child_sink, struct core_log_sink *sink)
{
struct core_log_sink_mutex_ctx *ctx;
ctx = xmalloc(sizeof(struct core_log_sink_mutex_ctx));
memcpy(ctx->child, child_sink, sizeof(struct core_log_sink));
ctx->mutex = CreateMutex(NULL, FALSE, NULL);
sink->ctx = ctx;
sink->write = _core_log_sink_mutex_write;
sink->close = _core_log_sink_mutex_close;
}

View File

@@ -1,21 +0,0 @@
#ifndef CORE_LOG_SINK_MUTEX_H
#define CORE_LOG_SINK_MUTEX_H
#include <stdlib.h>
#include "core/log-sink.h"
/**
* Create a sink that surrounds another sink with a mutex.
*
* Use this to make other sink implementations thread-safe.
*
* @param child_sink Another opened sink to surround with the mutex. Ownership
* of the sink is transferred, i.e. closing the mutex sink
* also closes the wrapped child sink.
* @param sink Pointer to allocated memory that receives the opened sink
*/
void core_log_sink_mutex_open(
const struct core_log_sink *child_sink, struct core_log_sink *sink);
#endif

View File

@@ -1,21 +0,0 @@
#include <stdlib.h>
#include "core/log-sink.h"
static void
_core_log_sink_null_write(void *ctx, const char *chars, size_t nchars)
{
// noop
}
static void _core_log_sink_null_close(void *ctx)
{
// noop
}
void core_log_sink_null_open(struct core_log_sink *sink)
{
sink->ctx = NULL;
sink->write = _core_log_sink_null_write;
sink->close = _core_log_sink_null_close;
}

View File

@@ -1,17 +0,0 @@
#ifndef CORE_LOG_SINK_NULL_H
#define CORE_LOG_SINK_NULL_H
#include <stdlib.h>
#include "core/log-sink.h"
/**
* Create a null/dummy sink.
*
* Use this to disable any logging entirely.
*
* @param sink Pointer to allocated memory that receives the opened sink
*/
void core_log_sink_null_open(struct core_log_sink *sink);
#endif

View File

@@ -1,193 +0,0 @@
#include <windows.h>
#include <stdlib.h>
#include "core/log-sink.h"
#include "util/mem.h"
struct core_log_sink_std_ctx {
HANDLE handle;
bool color;
};
static char _core_log_sink_std_determine_color(const char *str)
{
/* Add some color to make spotting warnings/errors easier.
Based on debug output level identifier. */
/* Avoids colored output on strings like "Windows" */
if (str[1] != ':') {
return 15;
}
switch (str[0]) {
/* green */
case 'M':
return 10;
/* blue */
case 'I':
return 9;
/* yellow */
case 'W':
return 14;
/* red */
case 'F':
return 12;
/* default console color */
default:
return 15;
}
}
static size_t _core_log_sink_std_msg_coloring_len(const char *str)
{
// Expected format example: "I:boot: my log message"
const char *ptr;
size_t len;
int colon_count;
ptr = str;
len = 0;
colon_count = 0;
while (true) {
// End of string = invalid log format
if (*ptr == '\0') {
return 0;
}
if (*ptr == ':') {
colon_count++;
}
if (colon_count == 2) {
// Skip current colon, next char is a space
return len + 1;
}
len++;
ptr++;
}
return 0;
}
static void
_core_log_sink_std_write(void *ctx_, const char *chars, size_t nchars)
{
static const size_t timestamp_len = strlen("[----/--/-- --:--:--]");
struct core_log_sink_std_ctx *ctx;
char color;
size_t color_len;
size_t msg_len;
const char *msg_start;
const char *msg_end;
DWORD written;
DWORD write_pos;
ctx = (struct core_log_sink_std_ctx *) ctx_;
if (ctx->color) {
write_pos = 0;
// Support multiple buffered log messages, e.g. from the AVS logging
// engine
while (write_pos < nchars) {
// Expects the AVS timestamp format
msg_start = chars + timestamp_len + 1; // +1 is the space
color_len = _core_log_sink_std_msg_coloring_len(msg_start);
// Check if we could detect which part to color, otherwise just
// write the whole log message without any coloring logic
if (color_len > 0) {
color = _core_log_sink_std_determine_color(msg_start);
// Timestamp
WriteConsole(
ctx->handle, chars, timestamp_len + 1, &written, NULL);
write_pos += written;
chars += written;
// Log level + module colored
SetConsoleTextAttribute(ctx->handle, color);
WriteConsole(ctx->handle, chars, color_len, &written, NULL);
write_pos += written;
chars += written;
SetConsoleTextAttribute(ctx->handle, 15);
msg_end = strchr(chars, '\n');
if (msg_end != NULL) {
msg_len = msg_end - chars;
// Write \n as well
msg_len++;
// Write actual message non colored
WriteConsole(ctx->handle, chars, msg_len, &written, NULL);
write_pos += written;
chars += written;
} else {
WriteConsole(
ctx->handle, chars, nchars - write_pos, &written, NULL);
write_pos += written;
chars += written;
}
} else {
WriteConsole(
ctx->handle,
chars + write_pos,
nchars - write_pos,
&written,
NULL);
write_pos += written;
}
}
} else {
WriteConsole(ctx->handle, chars, nchars, &written, NULL);
}
}
static void _core_log_sink_std_close(void *ctx_)
{
struct core_log_sink_std_ctx *ctx;
ctx = (struct core_log_sink_std_ctx *) ctx_;
// Remark: Don't close the ctx->handle, see win API docs
free(ctx);
}
void core_log_sink_std_out_open(bool color, struct core_log_sink *sink)
{
struct core_log_sink_std_ctx *ctx;
ctx = xmalloc(sizeof(struct core_log_sink_std_ctx));
ctx->handle = GetStdHandle(STD_OUTPUT_HANDLE);
ctx->color = color;
sink->ctx = (void *) ctx;
sink->write = _core_log_sink_std_write;
sink->close = _core_log_sink_std_close;
}
void core_log_sink_std_err_open(bool color, struct core_log_sink *sink)
{
struct core_log_sink_std_ctx *ctx;
ctx = xmalloc(sizeof(struct core_log_sink_std_ctx));
ctx->handle = GetStdHandle(STD_ERROR_HANDLE);
ctx->color = color;
sink->ctx = (void *) ctx;
sink->write = _core_log_sink_std_write;
sink->close = _core_log_sink_std_close;
}

View File

@@ -1,24 +0,0 @@
#ifndef CORE_LOG_SINK_STD_H
#define CORE_LOG_SINK_STD_H
#include <stdlib.h>
#include "core/log-sink.h"
/**
* Create a sink that writes to stdout.
*
* @param color If true, messages are colored by log level.
* @param sink Pointer to allocated memory that receives the opened sink
*/
void core_log_sink_std_out_open(bool color, struct core_log_sink *sink);
/**
* Create a sink that writes to stderr.
*
* @param color If true, messages are colored by log level.
* @param sink Pointer to allocated memory that receives the opened sink
*/
void core_log_sink_std_err_open(bool color, struct core_log_sink *sink);
#endif

View File

@@ -1,45 +0,0 @@
#ifndef CORE_LOG_SINK_H
#define CORE_LOG_SINK_H
#include <stdint.h>
/**
* Write function for a log sink implementation.
*
* Write the given data to your target output destination.
*
* @param ctx Context defined by the implementation when opening the sink.
* @param chars Buffer with text data to log. This can contain partial data of
* a single log line, a full log line terminated by a newline
* character or multiple log lines (each terminated by a newline
* character).
* @param nchars Number of characters to write.
*/
typedef void (*core_log_sink_write_t)(
void *ctx, const char *chars, size_t nchars);
/**
* Close your log sink and cleanup resources
*
* Depending on your implementation, you might want to flush any
* outstanding/buffered data.
*
* @param ctx Context defined by the implementation when opening the sink.
*/
typedef void (*core_log_sink_close_t)(void *ctx);
/**
* Log sink structure.
*
* This must be set-up and populated when opening your log sink implementation.
* The ctx field contains any arbitrary data that you need for your log sink
* to operate, e.g. a file handle, additional buffers etc. Make sure these
* resources are cleaned up upon closing the sink.
*/
struct core_log_sink {
void *ctx;
core_log_sink_write_t write;
core_log_sink_close_t close;
};
#endif

View File

@@ -1,74 +0,0 @@
#include <stdlib.h>
#include "core/log.h"
core_log_message_t _core_log_misc_impl;
core_log_message_t _core_log_info_impl;
core_log_message_t _core_log_warning_impl;
core_log_message_t _core_log_fatal_impl;
void core_log_impl_set(
core_log_message_t misc,
core_log_message_t info,
core_log_message_t warning,
core_log_message_t fatal)
{
if (misc == NULL || info == NULL || warning == NULL || fatal == NULL) {
abort();
}
_core_log_misc_impl = misc;
_core_log_info_impl = info;
_core_log_warning_impl = warning;
_core_log_fatal_impl = fatal;
}
void core_log_impl_assign(core_log_impl_set_t impl_set)
{
if (_core_log_misc_impl == NULL || _core_log_info_impl == NULL ||
_core_log_warning_impl == NULL || _core_log_fatal_impl == NULL) {
abort();
}
impl_set(
_core_log_misc_impl,
_core_log_info_impl,
_core_log_warning_impl,
_core_log_fatal_impl);
}
core_log_message_t core_log_misc_impl_get()
{
if (_core_log_misc_impl == NULL) {
abort();
}
return _core_log_misc_impl;
}
core_log_message_t core_log_info_impl_get()
{
if (_core_log_info_impl == NULL) {
abort();
}
return _core_log_info_impl;
}
core_log_message_t core_log_warning_impl_get()
{
if (_core_log_warning_impl == NULL) {
abort();
}
return _core_log_warning_impl;
}
core_log_message_t core_log_fatal_impl_get()
{
if (_core_log_fatal_impl == NULL) {
abort();
}
return _core_log_fatal_impl;
}

View File

@@ -1,197 +0,0 @@
#ifndef CORE_LOG_H
#define CORE_LOG_H
#include <stddef.h>
#include <stdlib.h>
#include "util/defs.h"
/**
* The core log API of bemanitools.
*
* To a large extent, this reflects the AVS logging API and allows for swapping
* out the backends with different implementations. Most games should have some
* version of the AVS API available while some (legacy) games do not. These
* can use a bemanitools private logging implementation by configuring it
* in the bootstrapping process.
*/
/* BUILD_MODULE is passed in as a command-line #define by the makefile */
#ifndef LOG_MODULE
#define LOG_MODULE STRINGIFY(BUILD_MODULE)
#endif
/**
* Log a message on misc level
*
* Always use this interface in your application which hides the currently
* configured implementation.
*
* The macro is required to make things work with varargs.
* The log message is only printed if the log level is set to misc
*
* @param fmt printf format string
* @param ... Additional arguments according to the specified arguments in the
* printf format string
*/
#define log_misc(...) _core_log_misc_impl(LOG_MODULE, __VA_ARGS__)
/**
* Log a message on info level
*
* Always use this interface in your application which hides the currently
* configured implementation.
*
* The macro is required to make things work with varargs.
* The log message is only printed if the log level is set to info or lower
*
* @param fmt printf format string
* @param ... Additional arguments according to the specified arguments in the
* printf format string
*/
#define log_info(...) _core_log_info_impl(LOG_MODULE, __VA_ARGS__)
/**
* Log a message on warning level
*
* Always use this interface in your application which hides the currently
* configured implementation.
*
* The macro is required to make things work with varargs.
* The log message is only printed if the log level is set to warning or lower
*
* @param fmt printf format string
* @param ... Additional arguments according to the specified arguments in the
* printf format string
*/
#define log_warning(...) _core_log_warning_impl(LOG_MODULE, __VA_ARGS__)
/**
* Log a message on fatal level
*
* Always use this interface in your application which hides the currently
* configured implementation.
*
* The macro is required to make things work with varargs.
* The log message is only printed if the log level is set to fatal.
*
* This call will also terminate the application.
*
* @param fmt printf format string
* @param ... Additional arguments according to the specified arguments in the
* printf format string
*/
#define log_fatal(...) \
do { \
_core_log_fatal_impl(LOG_MODULE, __VA_ARGS__); \
abort(); \
} while (0)
/**
* Log a message and terminate the application if given condition fails
*
* Always use this interface in your application which hides the currently
* configured implementation.
*
* The macro is required to make things work with varargs.
*
* @param x Condition to evaluate. If false, the application terminates
*/
#define log_assert(x) \
do { \
if (!(x)) { \
_core_log_fatal_impl( \
"assert", \
"%s:%d: function `%s'", \
__FILE__, \
__LINE__, \
__FUNCTION__); \
abort(); \
} \
} while (0)
/**
* Log a message in an exception handler
*
* Only use this function in an exception handler, e.g. for stack traces. It
* logs the message on fatal level but does not terminate.
*
* @param fmt printf format string
* @param ... Additional arguments according to the specified arguments in the
* printf format string
*/
#define log_exception_handler(...) \
_core_log_fatal_impl("exception", __VA_ARGS__)
typedef void (*core_log_message_t)(const char *module, const char *fmt, ...);
typedef void (*core_log_impl_set_t)(
core_log_message_t misc,
core_log_message_t info,
core_log_message_t warning,
core_log_message_t fatal);
/**
* Configure the log API implementations
*
* Advised to do this as early in your application/library module as possible
* as calls to the getter functions below will return the currently configured
* implementations.
*
* @param misc Pointer to a function implementing logging on misc level
* @param info Pointer to a function implementing logging on info level
* @param warning Pointer to a function implementing logging on warning level
* @param fatal Pointer to a function implementing logging on fatal level
*/
void core_log_impl_set(
core_log_message_t misc,
core_log_message_t info,
core_log_message_t warning,
core_log_message_t fatal);
/**
* Supporting function to inject/assign the currently set implementation
* with the given setter function.
*
* @param impl_set Setter function to call with the currently configured log
* function implementations
*/
void core_log_impl_assign(core_log_impl_set_t impl_set);
/**
* Get the currently configured implementation of the misc level log function
*
* @return Pointer to the currently configured implementation of the function
*/
core_log_message_t core_log_misc_impl_get();
/**
* Get the currently configured implementation of the info level log function
*
* @return Pointer to the currently configured implementation of the function
*/
core_log_message_t core_log_info_impl_get();
/**
* Get the currently configured implementation of the warning level log function
*
* @return Pointer to the currently configured implementation of the function
*/
core_log_message_t core_log_warning_impl_get();
/**
* Get the currently configured implementation of the fatal level log function
*
* @return Pointer to the currently configured implementation of the function
*/
core_log_message_t core_log_fatal_impl_get();
// Do not use these directly.
// These are only here to allow usage in the macros above.
extern core_log_message_t _core_log_misc_impl;
extern core_log_message_t _core_log_info_impl;
extern core_log_message_t _core_log_warning_impl;
extern core_log_message_t _core_log_fatal_impl;
#endif

View File

@@ -1,8 +0,0 @@
#include "core/thread-crt.h"
#include "core/thread.h"
void core_thread_crt_ext_impl_set()
{
core_thread_impl_set(
core_thread_crt_create, core_thread_crt_join, core_thread_crt_destroy);
}

View File

@@ -1,9 +0,0 @@
#ifndef CORE_THREAD_CRT_EXT_H
#define CORE_THREAD_CRT_EXT_H
/**
* Set the current thread API implementation to use the C runtime thread API
*/
void core_thread_crt_ext_impl_set();
#endif

View File

@@ -1,62 +0,0 @@
#include <process.h>
#include <windows.h>
#include <stddef.h>
#include <stdint.h>
#include "core/thread-crt.h"
#include "core/thread.h"
#include "util/defs.h"
struct shim_ctx {
HANDLE barrier;
int (*proc)(void *);
void *ctx;
};
static unsigned int STDCALL crt_thread_shim(void *outer_ctx)
{
struct shim_ctx *sctx = outer_ctx;
int (*proc)(void *);
void *inner_ctx;
proc = sctx->proc;
inner_ctx = sctx->ctx;
SetEvent(sctx->barrier);
return proc(inner_ctx);
}
int core_thread_crt_create(
int (*proc)(void *), void *ctx, uint32_t stack_sz, unsigned int priority)
{
struct shim_ctx sctx;
uintptr_t thread_id;
sctx.barrier = CreateEvent(NULL, TRUE, FALSE, NULL);
sctx.proc = proc;
sctx.ctx = ctx;
thread_id = _beginthreadex(NULL, stack_sz, crt_thread_shim, &sctx, 0, NULL);
WaitForSingleObject(sctx.barrier, INFINITE);
CloseHandle(sctx.barrier);
return (int) thread_id;
}
void core_thread_crt_destroy(int thread_id)
{
CloseHandle((HANDLE) (uintptr_t) thread_id);
}
void core_thread_crt_join(int thread_id, int *result)
{
WaitForSingleObject((HANDLE) (uintptr_t) thread_id, INFINITE);
if (result) {
GetExitCodeThread((HANDLE) (uintptr_t) thread_id, (DWORD *) result);
}
}

View File

@@ -1,15 +0,0 @@
#ifndef CORE_THREAD_CRT_H
#define CORE_THREAD_CRT_H
#include <stdint.h>
/**
* Thread API implementation using the C runtime API
*/
int core_thread_crt_create(
int (*proc)(void *), void *ctx, uint32_t stack_sz, unsigned int priority);
void core_thread_crt_join(int thread_id, int *result);
void core_thread_crt_destroy(int thread_id);
#endif

View File

@@ -1,78 +0,0 @@
#include <stdlib.h>
#include "core/log.h"
#include "core/thread.h"
core_thread_create_t core_thread_create_impl;
core_thread_join_t core_thread_join_impl;
core_thread_destroy_t core_thread_destroy_impl;
int core_thread_create(
int (*proc)(void *), void *ctx, uint32_t stack_sz, unsigned int priority)
{
log_assert(core_thread_create_impl);
return core_thread_create_impl(proc, ctx, stack_sz, priority);
}
void core_thread_join(int thread_id, int *result)
{
log_assert(core_thread_join_impl);
core_thread_join_impl(thread_id, result);
}
void core_thread_destroy(int thread_id)
{
log_assert(core_thread_destroy_impl);
core_thread_destroy_impl(thread_id);
}
void core_thread_impl_set(
core_thread_create_t create,
core_thread_join_t join,
core_thread_destroy_t destroy)
{
if (create == NULL || join == NULL || destroy == NULL) {
abort();
}
core_thread_create_impl = create;
core_thread_join_impl = join;
core_thread_destroy_impl = destroy;
}
void core_thread_impl_assign(core_thread_impl_set_t impl_set)
{
if (core_thread_create_impl == NULL || core_thread_join_impl == NULL ||
core_thread_destroy_impl == NULL) {
abort();
}
impl_set(
core_thread_create_impl,
core_thread_join_impl,
core_thread_destroy_impl);
}
core_thread_create_t core_thread_create_impl_get()
{
log_assert(core_thread_create_impl);
return core_thread_create_impl;
}
core_thread_join_t core_thread_join_impl_get()
{
log_assert(core_thread_join_impl);
return core_thread_join_impl;
}
core_thread_destroy_t core_thread_destroy_impl_get()
{
log_assert(core_thread_destroy_impl);
return core_thread_destroy_impl;
}

View File

@@ -1,117 +0,0 @@
#ifndef CORE_THREAD_H
#define CORE_THREAD_H
#include <stdint.h>
/**
* The core thread API of bemanitools.
*
* This essentially reflects the AVS threading API and allows for swapping out
* the backends with different implementations. Most games should have some
* version of the AVS API available while some (legacy) games do not. These
* can use a bemanitools private threading implementation by configuring it
* in the bootstrapping process.
*/
/**
* Create a thread
*
* Always use this interface in your application which hides the currently
* configured implementation.
*
* @param proc The function to run in a separate thread
* @param ctx Additional data to pass to the function as a parameter
* @param stack_sz The stack size to allocate for the thread in bytes
* @param priority The thread's priority
* @return The ID of the thread once created and started
*/
int core_thread_create(
int (*proc)(void *), void *ctx, uint32_t stack_sz, unsigned int priority);
/**
* Wait for a thread to finish
*
* Always use this interface in your application which hides the currently
* configured implementation.
*
* The caller of this function blocks until the thread has finished executing.
*
* @param thread_id ID of the thread to wait for
* @param result Pointer to a variable to write the return value of the function
* the thread executed to
*/
void core_thread_join(int thread_id, int *result);
/**
* Destroy a thread
*
* Always use this interface in your application which hides the currently
* configured implementation.
*
* The thread must have finished execution before calling this. It is advised
* to make threads terminate their execution flow, join them and destroy.
*
* @param thread_id The ID of the thread to destroy.
*/
void core_thread_destroy(int thread_id);
typedef int (*core_thread_create_t)(
int (*proc)(void *), void *ctx, uint32_t stack_sz, unsigned int priority);
typedef void (*core_thread_join_t)(int thread_id, int *result);
typedef void (*core_thread_destroy_t)(int thread_id);
typedef void (*core_thread_impl_set_t)(
core_thread_create_t create,
core_thread_join_t join,
core_thread_destroy_t destroy);
/**
* Configure the thread API implementations
*
* Advised to do this as early in your application/library module as possible
* as calls to the getter functions below will return the currently configured
* implementations.
*
* @param create Pointer to a function implementing thread creation
* @param join Pointer to a function implementing joining of a thread
* @param destroy Pointer to a function implementing destroying of a thread
*/
void core_thread_impl_set(
core_thread_create_t create,
core_thread_join_t join,
core_thread_destroy_t destroy);
/**
* Supporting function to inject/assign the currently set implementation
* with the given setter function.
*
* @param impl_set Setter function to call with the currently configured thread
* function implementations
*/
void core_thread_impl_assign(core_thread_impl_set_t impl_set);
/**
* Get the currently configured implementation for thread_create
*
* @return Pointer to the currently configured implementation of the
* thread_create function
*/
core_thread_create_t core_thread_create_impl_get();
/**
* Get the currently configured implementation for thread_join
*
* @return Pointer to the currently configured implementation of the thread_join
* function
*/
core_thread_join_t core_thread_join_impl_get();
/**
* Get the currently configured implementation for thread_destroy
*
* @return Pointer to the currently configured implementation of the
* thread_destroy function
*/
core_thread_destroy_t core_thread_destroy_impl_get();
#endif

View File

@@ -0,0 +1,16 @@
dlls += d3d9-frame-graph-hook
ldflags_d3d9-frame-graph-hook := \
-ld3d9 \
-ldwmapi\
-lgdi32 \
libs_d3d9-frame-graph-hook := \
hook \
imgui-bt \
imgui-debug \
imgui \
util \
src_d3d9-frame-graph-hook := \
main.c \

View File

@@ -0,0 +1,4 @@
LIBRARY d3d9-frame-graph-hook
EXPORTS
DllMain@12 @1 NONAME

View File

@@ -0,0 +1,32 @@
#include <windows.h>
#include "hook/d3d9.h"
#include "hook/table.h"
#include "imgui-bt/imgui-d3d9-hook.h"
#include "imgui-debug/frame-perf-graph.h"
#include "util/defs.h"
#include "util/log.h"
static const hook_d3d9_irp_handler_t d3d9_frame_graph_hook_handlers[] = {
imgui_hook_d3d9_irp_handler
};
BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
{
imgui_bt_component_t debug_frame_graph_component;
if (reason == DLL_PROCESS_ATTACH) {
log_to_writer(log_writer_null, NULL);
imgui_debug_frame_perf_graph_init(60.0f, &debug_frame_graph_component);
imgui_d3d9_hook_init(&debug_frame_graph_component, 1);
hook_d3d9_init(d3d9_frame_graph_hook_handlers, lengthof(d3d9_frame_graph_hook_handlers));
}
return TRUE;
}

View File

@@ -0,0 +1,22 @@
exes += d3d9-monitor-check \
ldflags_d3d9-monitor-check := \
-ld3d9 \
-ldwmapi \
-lgdi32 \
-ld3dx9 \
libs_d3d9-monitor-check := \
util \
src_d3d9-monitor-check := \
cmdline.c \
font.c \
gfx.c \
input.c \
interactive.c \
main.c \
menu.c \
refresh-rate-test.c \
response-time-test.c \
vsync-test.c

View File

@@ -0,0 +1,534 @@
#include <stdbool.h>
#include <stdint.h>
#include "d3d9-monitor-check/gfx.h"
#include "d3d9-monitor-check/input.h"
#include "d3d9-monitor-check/print-console.h"
#include "d3d9-monitor-check/refresh-rate-test.h"
#include "d3d9-monitor-check/response-time-test.h"
#include "d3d9-monitor-check/vsync-test.h"
static void _print_synopsis()
{
printfln_err("D3D9 monitor check tool command line mode");
printfln_err("");
printfln_err("Usage:");
printfln_err(" d3d9-monitor-check cmdline <command> <args>");
printfln_err("");
printfln_err("Available commands:");
printfln_err(" adapter: Query adapter information");
printfln_err(" modes: Query adapter modes. Use this to get supported mandatory parameters for width, height and refresh rate for the tests.");
printfln_err("");
printfln_err(" refresh-rate-test <width> <height> <refresh_rate> [--warm-up-secs n] [--total-secs n] [--results-timeout-secs n] [--windowed] [--vsync-off]: Run a display refresh rate test (i.e. IIDX monitor check).");
printfln_err(" width: Width of the rendering resolution to run the test at");
printfln_err(" height: Height of the rendering resolution to run the test at");
printfln_err(" refresh_rate: Target refresh rate to run the test at");
printfln_err(" warm-up-secs: Optional. Number of seconds to warm-up before executing the main run that counts towards the measurement results");
printfln_err(" total-secs: Optional. Total number of seconds to run the test for that count towards the measurement results");
printfln_err(" results-timeout-secs: Optional. Number of seconds to display final result after the test before exiting");
printfln_err(" windowed: Optional. Run the test in windowed mode (not recommended)");
printfln_err(" vsync-off: Optional. Run the test with vsync off (not recommended)");
printfln_err("");
printfln_err(" response-time-test <width> <height> <refresh_rate> [--total-secs n] [--windowed] [--vsync-off]: Run a test to visually inspect the display's response times.");
printfln_err(" width: Width of the rendering resolution to run the test at");
printfln_err(" height: Height of the rendering resolution to run the test at");
printfln_err(" refresh_rate: Target refresh rate to run the test at");
printfln_err(" total-secs: Optional. Total number of seconds to run the test for that count towards the measurement results");
printfln_err(" windowed: Optional. Run the test in windowed mode (not recommended)");
printfln_err(" vsync-off: Optional. Run the test with vsync off (not recommended)");
printfln_err("");
printfln_err(" vsync-test <width> <height> <refresh_rate> [--total-secs n] [--windowed]: Run a test to visually inspect the display's vsync behavior.");
printfln_err(" width: Width of the rendering resolution to run the test at");
printfln_err(" height: Height of the rendering resolution to run the test at");
printfln_err(" refresh_rate: Target refresh rate to run the test at");
printfln_err(" total-secs: Optional. Total number of seconds to run the test for that count towards the measurement results");
printfln_err(" windowed: Optional. Run the test in windowed mode (not recommended)");
}
static bool _adapter()
{
D3DADAPTER_IDENTIFIER9 identifier;
if (!gfx_adapter_info_get(&identifier)) {
return false;
}
printfln_out("Driver: %s", identifier.Driver);
printfln_out("Description: %s", identifier.Description);
printfln_out("DeviceName: %s", identifier.DeviceName);
#ifdef _WIN32
printfln_out("DriverVersion: %lld", identifier.DriverVersion.QuadPart);
#else
printfln_out("DriverVersion: %lu.%lu", identifier.DriverVersionHighPart, identifier.DriverVersionLowPart);
#endif
printfln_out("VendorId: %lu", identifier.VendorId);
printfln_out("DeviceId: %lu", identifier.DeviceId);
printfln_out("SubSysId: %lu", identifier.SubSysId);
printfln_out("Revision: %lu", identifier.Revision);
printfln_out("DeviceIdentifier: {%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
identifier.DeviceIdentifier.Data1,
identifier.DeviceIdentifier.Data2,
identifier.DeviceIdentifier.Data3,
identifier.DeviceIdentifier.Data4[0],
identifier.DeviceIdentifier.Data4[1],
identifier.DeviceIdentifier.Data4[2],
identifier.DeviceIdentifier.Data4[3],
identifier.DeviceIdentifier.Data4[4],
identifier.DeviceIdentifier.Data4[5],
identifier.DeviceIdentifier.Data4[6],
identifier.DeviceIdentifier.Data4[7]);
printfln_out("WHQLLevel: %lu", identifier.WHQLLevel);
return true;
}
static bool _modes()
{
gfx_adapter_modes_t modes;
if (!gfx_adapter_modes_get(&modes)) {
return false;
}
for (uint32_t i = 0; i < modes.count; i++) {
printfln_out("%d: %d x %d @ %d hz", i, modes.modes[i].Width, modes.modes[i].Height, modes.modes[i].RefreshRate);
}
return true;
}
static bool _refresh_rate_test(
uint32_t width,
uint32_t height,
uint32_t refresh_rate,
uint32_t warm_up_frame_count,
uint32_t sample_frame_count,
uint32_t result_timeout_frame_count,
bool windowed,
bool vsync)
{
gfx_t *gfx;
input_t *input;
refresh_rate_test_t *test;
gfx_info_t gfx_info;
refresh_rate_test_results_t results;
uint32_t results_timeout_seconds;
input_init(&input);
if (!gfx_init(width, height, refresh_rate, windowed, vsync, &gfx)) {
input_fini(input);
return false;
}
if (!refresh_rate_test_init(gfx, warm_up_frame_count, sample_frame_count, &test)) {
input_fini(input);
gfx_fini(gfx);
return false;
}
do {
input_update(input);
if (input_key_esc_pushed(input)) {
break;
}
} while (refresh_rate_test_frame_update(test) &&
gfx_last_frame_count_get(gfx) < warm_up_frame_count + sample_frame_count);
results_timeout_seconds = result_timeout_frame_count / refresh_rate;
// Display final results
for (uint32_t i = 0; i < result_timeout_frame_count; i++) {
input_update(input);
if (input_key_esc_pushed(input)) {
break;
}
if (!refresh_rate_test_results_frame_update(test, results_timeout_seconds)) {
break;
}
}
gfx_info_get(gfx, &gfx_info);
refresh_rate_test_results_get(test, &results);
printfln_err("Final results");
printfln_out("GPU: %s", gfx_info.adapter_identifier);
printfln_out("Spec: %d x %d @ %d hz, %s, vsync %s", gfx_info.width, gfx_info.height, gfx_info.refresh_rate,
gfx_info.windowed ? "windowed" : "fullscreen", gfx_info.vsync ? "on" : "off");
printfln_out("Total warm-up frame count: %d", results.total_warm_up_frame_count);
printfln_out("Total sample frame count: %d", results.total_sample_frame_count);
printfln_out("Avg frame time (ms): %.3f", results.avg_frame_time_ms);
printfln_out("Avg refresh rate (hz): %.3f", results.avg_refresh_rate_hz);
refresh_rate_test_fini(test);
input_fini(input);
gfx_fini(gfx);
return true;
}
static bool _response_time_test(
uint32_t width,
uint32_t height,
uint32_t refresh_rate,
uint32_t total_frame_count,
bool windowed,
bool vsync)
{
gfx_t *gfx;
input_t *input;
response_time_test_t *test;
input_init(&input);
// Force vsync on, off option doesn't make sense for this test
if (!gfx_init(width, height, refresh_rate, windowed, vsync, &gfx)) {
input_fini(input);
return false;
}
if (!response_time_test_init(gfx, &test)) {
input_fini(input);
gfx_fini(gfx);
return false;
}
do {
input_update(input);
if (input_key_esc_pushed(input)) {
break;
}
} while (response_time_test_frame_update(test) &&
gfx_last_frame_count_get(gfx) < total_frame_count);
response_time_test_fini(test);
input_fini(input);
gfx_fini(gfx);
return true;
}
static bool _vsync_test(
uint32_t width,
uint32_t height,
uint32_t refresh_rate,
uint32_t total_frame_count,
bool windowed)
{
gfx_t *gfx;
input_t *input;
vsync_test_t *test;
input_init(&input);
// Force vsync on, off option doesn't make sense for this test
if (!gfx_init(width, height, refresh_rate, windowed, true, &gfx)) {
input_fini(input);
return false;
}
if (!vsync_test_init(gfx, &test)) {
input_fini(input);
gfx_fini(gfx);
return false;
}
do {
input_update(input);
if (input_key_esc_pushed(input)) {
break;
}
} while (vsync_test_frame_update(test) &&
gfx_last_frame_count_get(gfx) < total_frame_count);
vsync_test_fini(test);
input_fini(input);
gfx_fini(gfx);
return true;
}
static bool _cmd_refresh_rate_test(int argc, char **argv)
{
uint32_t width;
uint32_t height;
uint32_t refresh_rate;
uint32_t warm_up_seconds;
uint32_t sample_seconds;
uint32_t results_timeout_seconds;
bool windowed;
bool vsync;
uint32_t total_warm_up_frame_count;
uint32_t total_sample_frame_count;
uint32_t result_timeout_frame_count;
if (argc < 3) {
_print_synopsis();
printfln_err("ERROR: Insufficient arguments");
return false;
}
width = atoi(argv[0]);
if (width == 0 || width > 16384) {
_print_synopsis();
printfln_err("ERROR: Invalid width: %d", width);
return false;
}
height = atoi(argv[1]);
if (height == 0 || height > 16384) {
_print_synopsis();
printfln_err("ERROR: Invalid height: %d", height);
return false;
}
refresh_rate = atoi(argv[2]);
if (refresh_rate == 0 || refresh_rate > 1000) {
_print_synopsis();
printfln_err("ERROR: Invalid refresh rate: %d", refresh_rate);
return false;
}
// Sane defaults
warm_up_seconds = 10;
sample_seconds = 20;
results_timeout_seconds = 5;
windowed = false;
vsync = true;
for (int i = 3; i < argc; i++) {
if (!strcmp(argv[i], "--warm-up-secs")) {
if (i + 1 < argc) {
warm_up_seconds = atoi(argv[++i]);
if (warm_up_seconds == 0) {
_print_synopsis();
printfln_err("ERROR: Invalid warm-up seconds: %d", warm_up_seconds);
return false;
}
} else {
_print_synopsis();
printfln_err("ERROR: Missing argument for --warm-up-secs");
return false;
}
} else if (!strcmp(argv[i], "--sample-secs")) {
if (i + 1 < argc) {
sample_seconds = atoi(argv[++i]);
if (sample_seconds == 0) {
_print_synopsis();
printfln_err("ERROR: Invalid sample seconds: %d", sample_seconds);
return false;
}
} else {
_print_synopsis();
printfln_err("ERROR: Missing argument for --total-secs");
return false;
}
} else if (!strcmp(argv[i], "--results-timeout-secs")) {
if (i + 1 < argc) {
results_timeout_seconds = atoi(argv[++i]);
} else {
_print_synopsis();
printfln_err("ERROR: Missing argument for --results-timeout-secs");
}
} else if (!strcmp(argv[i], "--windowed")) {
windowed = true;
} else if (!strcmp(argv[i], "--vsync-off")) {
vsync = false;
}
}
total_warm_up_frame_count = warm_up_seconds * refresh_rate;
total_sample_frame_count = sample_seconds * refresh_rate;
result_timeout_frame_count = results_timeout_seconds * refresh_rate;
return _refresh_rate_test(
width,
height,
refresh_rate,
total_warm_up_frame_count,
total_sample_frame_count,
result_timeout_frame_count,
windowed,
vsync);
}
static bool _cmd_response_time_test(int argc, char **argv)
{
uint32_t width;
uint32_t height;
uint32_t refresh_rate;
uint32_t total_seconds;
bool windowed;
bool vsync;
uint32_t total_frame_count;
if (argc < 3) {
_print_synopsis();
printfln_err("ERROR: Insufficient arguments");
return false;
}
width = atoi(argv[0]);
if (width == 0 || width > 16384) {
_print_synopsis();
printfln_err("ERROR: Invalid width: %d", width);
return false;
}
height = atoi(argv[1]);
if (height == 0 || height > 16384) {
_print_synopsis();
printfln_err("ERROR: Invalid height: %d", height);
return false;
}
refresh_rate = atoi(argv[2]);
if (refresh_rate == 0 || refresh_rate > 1000) {
_print_synopsis();
printfln_err("ERROR: Invalid refresh rate: %d", refresh_rate);
return false;
}
// Sane defaults
total_seconds = 30;
windowed = false;
vsync = true;
for (int i = 3; i < argc; i++) {
if (!strcmp(argv[i], "--total-secs")) {
if (i + 1 < argc) {
total_seconds = atoi(argv[++i]);
if (total_seconds == 0) {
_print_synopsis();
printfln_err("ERROR: Invalid total seconds: %d", total_seconds);
return false;
}
} else {
_print_synopsis();
printfln_err("ERROR: Missing argument for --total-secs");
return false;
}
} else if (!strcmp(argv[i], "--windowed")) {
windowed = true;
} else if (!strcmp(argv[i], "--vsync-off")) {
vsync = false;
}
}
total_frame_count = total_seconds * refresh_rate;
return _response_time_test(width, height, refresh_rate, total_frame_count, windowed, vsync);
}
static bool _cmd_vsync_test(int argc, char **argv)
{
uint32_t width;
uint32_t height;
uint32_t refresh_rate;
uint32_t total_seconds;
bool windowed;
uint32_t total_frame_count;
if (argc < 3) {
_print_synopsis();
printfln_err("ERROR: Insufficient arguments");
return false;
}
width = atoi(argv[0]);
if (width == 0 || width > 16384) {
_print_synopsis();
printfln_err("ERROR: Invalid width: %d", width);
return false;
}
height = atoi(argv[1]);
if (height == 0 || height > 16384) {
_print_synopsis();
printfln_err("ERROR: Invalid height: %d", height);
return false;
}
refresh_rate = atoi(argv[2]);
if (refresh_rate == 0 || refresh_rate > 1000) {
_print_synopsis();
printfln_err("ERROR: Invalid refresh rate: %d", refresh_rate);
return false;
}
// Sane defaults
total_seconds = 30;
windowed = false;
for (int i = 3; i < argc; i++) {
if (!strcmp(argv[i], "--total-secs")) {
if (i + 1 < argc) {
total_seconds = atoi(argv[++i]);
if (total_seconds == 0) {
_print_synopsis();
printfln_err("ERROR: Invalid total seconds: %d", total_seconds);
return false;
}
} else {
_print_synopsis();
printfln_err("ERROR: Missing argument for --total-secs");
return false;
}
} else if (!strcmp(argv[i], "--windowed")) {
windowed = true;
}
}
total_frame_count = total_seconds * refresh_rate;
return _vsync_test(width, height, refresh_rate, total_frame_count, windowed);
}
bool cmdline_main(int argc, char **argv)
{
const char *command;
if (argc < 1) {
_print_synopsis();
printfln_err("ERROR: Insufficient arguments");
return false;
}
command = argv[0];
if (!strcmp(command, "adapter")) {
return _adapter();
} else if (!strcmp(command, "modes")) {
return _modes();
} else if (!strcmp(command, "refresh-rate-test")) {
return _cmd_refresh_rate_test(argc - 1, argv + 1);
} else if (!strcmp(command, "response-time-test")) {
return _cmd_response_time_test(argc - 1, argv + 1);
} else if (!strcmp(command, "vsync-test")) {
return _cmd_vsync_test(argc - 1, argv + 1);
} else {
_print_synopsis(argv[0]);
printfln_err("ERROR: Unknown command: %s", command);
return false;
}
}

View File

@@ -0,0 +1,8 @@
#ifndef D3D9_MONITOR_CHECK_CMDLINE_H
#define D3D9_MONITOR_CHECK_CMDLINE_H
#include <stdbool.h>
bool cmdline_main(int argc, char **argv);
#endif

View File

@@ -0,0 +1,207 @@
#include <windows.h>
#include <d3dx9.h>
#include <d3dx9core.h>
#include <assert.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "d3d9-monitor-check/font.h"
#include "d3d9-monitor-check/gfx.h"
#include "util/mem.h"
#define BASE_RESOLUTION_WIDTH 640.0f
#define BASE_RESOLUTION_HEIGHT 480.0f
#define BASE_FONT_SIZE 20.0f
#define BASE_MARGIN 1.0f
// Standard Windows DPI
#define BASE_DPI 96.0f
typedef struct font {
gfx_t *gfx;
ID3DXFont *font;
float scale_x;
float scale_y;
float dpi_scale;
uint32_t font_height;
uint32_t line_height;
uint32_t base_offset_x;
uint32_t base_offset_y;
} font_t;
static void _font_text_draw(font_t *font, uint32_t x, uint32_t y, uint8_t r, uint8_t g, uint8_t b, const char *text)
{
uint32_t scaled_x;
uint32_t scaled_y;
RECT rect;
assert(font);
assert(text);
// Scale position based on both resolution and DPI
scaled_x = (uint32_t)(x * font->scale_x * font->dpi_scale) + font->base_offset_x;
scaled_y = (uint32_t)(y * font->scale_y * font->dpi_scale) + font->base_offset_y;
rect.left = scaled_x;
rect.top = scaled_y;
// Scale text box width based on both resolution and DPI
rect.right = scaled_x + (uint32_t)(BASE_RESOLUTION_WIDTH * font->scale_x * font->dpi_scale);
rect.bottom = scaled_y + font->line_height;
ID3DXFont_DrawText(
font->font,
NULL,
text,
-1,
&rect,
DT_LEFT | DT_TOP | DT_NOCLIP,
D3DCOLOR_XRGB(r, g, b));
}
bool font_init(gfx_t *gfx, uint32_t size, font_t **font)
{
IDirect3DDevice9 *device;
HRESULT hr;
HDC hdc;
int dpi;
assert(gfx);
assert(font);
*font = xmalloc(sizeof(font_t));
memset(*font, 0, sizeof(font_t));
(*font)->gfx = gfx;
// Get the system DPI
hdc = GetDC(NULL);
dpi = GetDeviceCaps(hdc, LOGPIXELSY);
ReleaseDC(NULL, hdc);
// Calculate DPI scale relative to base DPI
(*font)->dpi_scale = dpi / BASE_DPI;
// Calculate resolution scaling factors
(*font)->scale_x = gfx_width_get(gfx) / BASE_RESOLUTION_WIDTH;
(*font)->scale_y = gfx_height_get(gfx) / BASE_RESOLUTION_HEIGHT;
// Scale font height based on both DPI and resolution
// This ensures text maintains physical size across different resolutions
(*font)->font_height = (uint32_t)(size * (*font)->dpi_scale);
// Line height matches font height
(*font)->line_height = (*font)->font_height;
// Scale margins based on DPI and resolution
(*font)->base_offset_x = (uint32_t)(BASE_MARGIN * (*font)->scale_x * (*font)->dpi_scale);
(*font)->base_offset_y = (uint32_t)(BASE_MARGIN * (*font)->scale_y * (*font)->dpi_scale);
device = gfx_device_get(gfx);
hr = D3DXCreateFont(
device,
(*font)->font_height,
0,
FW_BOLD,
1,
FALSE,
DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS,
ANTIALIASED_QUALITY, // Changed to antialiased for better readability
DEFAULT_PITCH | FF_DONTCARE,
"Arial",
&(*font)->font);
if (hr != D3D_OK) {
free(*font);
return false;
}
return true;
}
void font_fini(font_t *font)
{
assert(font);
ID3DXFont_Release(font->font);
free(font);
}
void font_text_begin(font_t *font, uint32_t line_spacing, uint32_t origin_x, uint32_t origin_y, font_text_t *text)
{
assert(font);
assert(text);
text->font = font;
text->line_spacing = line_spacing;
text->origin_x = origin_x;
text->origin_y = origin_y;
text->current_x = origin_x;
text->current_y = origin_y;
}
void font_text_white_draw(font_text_t *text, const char *fmt, ...)
{
va_list args;
char buffer[4096];
assert(text);
assert(fmt);
va_start(args, fmt);
vsprintf(buffer, fmt, args);
va_end(args);
_font_text_draw(text->font, text->current_x, text->current_y, 255, 255, 255, buffer);
}
void font_text_red_draw(font_text_t *text, const char *fmt, ...)
{
va_list args;
char buffer[4096];
assert(text);
assert(fmt);
va_start(args, fmt);
vsprintf(buffer, fmt, args);
va_end(args);
_font_text_draw(text->font, text->current_x, text->current_y, 255, 0, 0, buffer);
}
void font_text_cyan_draw(font_text_t *text, const char *fmt, ...)
{
va_list args;
char buffer[4096];
assert(text);
assert(fmt);
va_start(args, fmt);
vsprintf(buffer, fmt, args);
va_end(args);
_font_text_draw(text->font, text->current_x, text->current_y, 0, 255, 255, buffer);
}
void font_text_newline(font_text_t *text)
{
assert(text);
text->current_x = text->origin_x;
text->current_y += text->font->line_height + text->line_spacing;
}
void font_text_end(font_text_t *text)
{
assert(text);
memset(text, 0, sizeof(font_text_t));
}

View File

@@ -0,0 +1,37 @@
#ifndef D3D9_MONITOR_CHECK_FONT_H
#define D3D9_MONITOR_CHECK_FONT_H
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include "d3d9-monitor-check/gfx.h"
typedef struct font font_t;
typedef struct font_text {
font_t *font;
uint32_t line_spacing;
uint32_t origin_x;
uint32_t origin_y;
uint32_t current_x;
uint32_t current_y;
} font_text_t;
bool font_init(gfx_t *gfx, uint32_t size, font_t **font);
void font_fini(font_t *font);
void font_text_begin(font_t *font, uint32_t line_spacing, uint32_t origin_x, uint32_t origin_y, font_text_t *text);
void font_text_white_draw(font_text_t *text, const char *fmt, ...);
void font_text_red_draw(font_text_t *text, const char *fmt, ...);
void font_text_cyan_draw(font_text_t *text, const char *fmt, ...);
void font_text_newline(font_text_t *text);
void font_text_end(font_text_t *text);
#endif

View File

@@ -0,0 +1,430 @@
#include <windows.h>
#include <d3d9.h>
#include <d3dx9core.h>
#include <assert.h>
#include <stdbool.h>
#include <stdint.h>
#include "d3d9-monitor-check/gfx.h"
#include "d3d9-monitor-check/print-console.h"
#include "util/mem.h"
#include "util/time.h"
typedef struct gfx_ctx_t {
HWND hwnd;
IDirect3D9 *d3d;
IDirect3DDevice9 *device;
uint32_t width;
uint32_t height;
uint32_t refresh_rate;
bool windowed;
bool vsync;
} gfx_ctx_t;
typedef struct gfx_render_state_t {
uint64_t frame_current;
uint64_t frame_start_time;
uint64_t last_frame_time_us;
} gfx_render_state_t;
typedef struct gfx {
gfx_ctx_t ctx;
gfx_render_state_t render_state;
} gfx_t;
static const D3DFORMAT _gfx_d3dformat = D3DFMT_X8R8G8B8;
static bool _gfx_d3d_context_create(IDirect3D9 **d3d)
{
// Initialize D3D
*d3d = Direct3DCreate9(D3D_SDK_VERSION);
if (!*d3d) {
printfln_winerr("Creating d3d context failed");
return false;
}
return true;
}
static bool _gfx_adapter_identifier_query(IDirect3D9 *d3d, D3DADAPTER_IDENTIFIER9 *identifier)
{
HRESULT hr;
hr = IDirect3D9_GetAdapterIdentifier(d3d, D3DADAPTER_DEFAULT, 0, identifier);
if (hr != D3D_OK) {
printfln_winerr("GetAdapterIdentifier failed");
return false;
}
return true;
}
static bool _gfx_window_create(uint32_t width, uint32_t height, HWND *hwnd)
{
WNDCLASSEX wc;
memset(&wc, 0, sizeof(wc));
wc.cbSize = sizeof(wc);
wc.lpfnWndProc = DefWindowProc;
wc.hInstance = GetModuleHandle(NULL);
wc.lpszClassName = "D3D9MonitorCheck";
RegisterClassExA(&wc);
// Create window
*hwnd = CreateWindowA(
wc.lpszClassName,
"D3D9 Monitor Check",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
width,
height,
NULL,
NULL,
wc.hInstance,
NULL);
if (!*hwnd) {
printfln_winerr("Failed to create window");
return false;
}
return true;
}
static bool _gfx_d3d_device_create(
HWND hwnd,
IDirect3D9 *d3d,
uint32_t width,
uint32_t height,
uint32_t refresh_rate,
bool windowed,
bool vsync,
IDirect3DDevice9 **device)
{
D3DPRESENT_PARAMETERS pp;
HRESULT hr;
memset(&pp, 0, sizeof(pp));
if (windowed) {
ShowWindow(hwnd, SW_SHOW);
pp.Windowed = TRUE;
pp.FullScreen_RefreshRateInHz = 0;
} else {
ShowCursor(FALSE);
pp.Windowed = FALSE;
pp.FullScreen_RefreshRateInHz = refresh_rate;
}
if (vsync) {
pp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
} else {
pp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
}
pp.BackBufferWidth = width;
pp.BackBufferHeight = height;
pp.BackBufferFormat = _gfx_d3dformat;
pp.BackBufferCount = 2;
pp.MultiSampleType = D3DMULTISAMPLE_NONE;
pp.MultiSampleQuality = 0;
pp.SwapEffect = D3DSWAPEFFECT_DISCARD;
pp.hDeviceWindow = hwnd;
pp.EnableAutoDepthStencil = TRUE;
pp.AutoDepthStencilFormat = D3DFMT_D16;
pp.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
// Create D3D device
hr = IDirect3D9_CreateDevice(
d3d,
D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
hwnd,
D3DCREATE_HARDWARE_VERTEXPROCESSING,
&pp,
device);
if (hr != D3D_OK) {
printfln_winerr("Creating d3d device failed");
return false;
}
return true;
}
bool gfx_adapter_info_get(D3DADAPTER_IDENTIFIER9 *adapter)
{
IDirect3D9 *d3d;
assert(adapter);
memset(adapter, 0, sizeof(D3DADAPTER_IDENTIFIER9));
if (!_gfx_d3d_context_create(&d3d)) {
return false;
}
if (!_gfx_adapter_identifier_query(d3d, adapter)) {
IDirect3D9_Release(d3d);
return false;
}
IDirect3D9_Release(d3d);
return true;
}
bool gfx_adapter_modes_get(gfx_adapter_modes_t *modes)
{
IDirect3D9 *d3d;
HRESULT hr;
UINT mode_count;
assert(modes);
memset(modes, 0, sizeof(gfx_adapter_modes_t));
if (!_gfx_d3d_context_create(&d3d)) {
return false;
}
mode_count = IDirect3D9_GetAdapterModeCount(d3d, D3DADAPTER_DEFAULT, _gfx_d3dformat);
if (mode_count > sizeof(modes->modes)) {
mode_count = sizeof(modes->modes);
printfln_err("WARNING: Available adapter modes (total %d) is greater than the maximum supported modes in structure (%zu)", mode_count, sizeof(modes->modes));
}
for (UINT i = 0; i < mode_count; i++) {
hr = IDirect3D9_EnumAdapterModes(d3d, D3DADAPTER_DEFAULT, _gfx_d3dformat, i, &modes->modes[i]);
if (hr != D3D_OK) {
printfln_winerr("EnumAdapterMode index %d failed", i);
IDirect3D9_Release(d3d);
return false;
}
}
modes->count = mode_count;
IDirect3D9_Release(d3d);
return true;
}
bool gfx_init(
uint32_t width,
uint32_t height,
uint32_t refresh_rate,
bool windowed,
bool vsync,
gfx_t **gfx)
{
HWND hwnd;
IDirect3D9 *d3d;
D3DADAPTER_IDENTIFIER9 identifier;
IDirect3DDevice9 *device;
assert(gfx);
printfln_err("Creating d3d context ...");
if (!_gfx_d3d_context_create(&d3d)) {
return false;
}
printfln_err("Querying adapter identifier ...");
if (!_gfx_adapter_identifier_query(d3d, &identifier)) {
IDirect3D9_Release(d3d);
return false;
}
printfln_err("Adapter:");
printfln_err("Driver: %s", identifier.Driver);
printfln_err("Description: %s", identifier.Description);
printfln_err("DeviceName: %s", identifier.DeviceName);
#ifdef _WIN32
printfln_err("DriverVersion: %lld", identifier.DriverVersion.QuadPart);
#else
printfln_err("DriverVersion: %lu.%lu", identifier.DriverVersionHighPart, identifier.DriverVersionLowPart);
#endif
printfln_err("Creating window with %dx%d ...", width, height);
if (!_gfx_window_create(width, height, &hwnd)) {
IDirect3D9_Release(d3d);
return false;
}
printfln_err("Creating d3d device %d x %d @ %d hz %s vsync %s ...",
width,
height,
refresh_rate,
windowed ? "windowed" : "fullscreen",
vsync ? "on" : "off");
if (!_gfx_d3d_device_create(
hwnd,
d3d,
width,
height,
refresh_rate,
windowed,
vsync,
&device)) {
IDirect3D9_Release(d3d);
DestroyWindow(hwnd);
return false;
}
*gfx = xmalloc(sizeof(gfx_t));
memset(*gfx, 0, sizeof(gfx_t));
(*gfx)->ctx.hwnd = hwnd;
(*gfx)->ctx.d3d = d3d;
(*gfx)->ctx.device = device;
(*gfx)->ctx.width = width;
(*gfx)->ctx.height = height;
(*gfx)->ctx.refresh_rate = refresh_rate;
(*gfx)->ctx.windowed = windowed;
(*gfx)->ctx.vsync = vsync;
(*gfx)->render_state.frame_current = 0;
(*gfx)->render_state.frame_start_time = 0;
(*gfx)->render_state.last_frame_time_us = 0;
return true;
}
uint32_t gfx_width_get(gfx_t *gfx)
{
assert(gfx);
return gfx->ctx.width;
}
uint32_t gfx_height_get(gfx_t *gfx)
{
assert(gfx);
return gfx->ctx.height;
}
bool gfx_info_get(gfx_t *gfx, gfx_info_t *info)
{
D3DADAPTER_IDENTIFIER9 identifier;
assert(gfx);
assert(info);
if (!_gfx_adapter_identifier_query(gfx->ctx.d3d, &identifier)) {
return false;
}
strncpy(info->adapter_identifier, identifier.Description, sizeof(info->adapter_identifier));
info->width = gfx->ctx.width;
info->height = gfx->ctx.height;
info->refresh_rate = gfx->ctx.refresh_rate;
info->windowed = gfx->ctx.windowed;
info->vsync = gfx->ctx.vsync;
return true;
}
IDirect3DDevice9 *gfx_device_get(gfx_t *gfx)
{
assert(gfx);
return gfx->ctx.device;
}
bool gfx_frame_begin(gfx_t *gfx)
{
MSG msg;
assert(gfx);
// Required to not make windows think we are stuck and not responding
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
if (msg.message == WM_QUIT) {
return false;
}
TranslateMessage(&msg);
DispatchMessage(&msg);
}
IDirect3DDevice9_Clear(
gfx->ctx.device,
0,
NULL,
D3DCLEAR_TARGET,
D3DCOLOR_XRGB(0, 0, 0),
1.0f,
0);
IDirect3DDevice9_BeginScene(gfx->ctx.device);
return true;
}
void gfx_frame_end(gfx_t *gfx)
{
uint64_t end_time;
assert(gfx);
IDirect3DDevice9_EndScene(gfx->ctx.device);
IDirect3DDevice9_Present(gfx->ctx.device, NULL, NULL, NULL, NULL);
// End previous frame time measurement after the frame has been presented (which might include waiting for vsync)
// and start a new frame time measurement immediately
// This ensures that anything that comes after ending the frame and still before starting a new frame, e.g. IO
// processing, is included in the total frame time measurement
// However, this can not include the very first frame
if (gfx->render_state.frame_current > 0) {
end_time = time_get_counter();
gfx->render_state.last_frame_time_us = time_get_elapsed_us(end_time - gfx->render_state.frame_start_time);
gfx->render_state.frame_start_time = end_time;
}
gfx->render_state.frame_start_time = time_get_counter();
gfx->render_state.frame_current++;
}
uint64_t gfx_last_frame_count_get(gfx_t *gfx)
{
assert(gfx);
return gfx->render_state.frame_current;
}
uint64_t gfx_last_frame_time_us_get(gfx_t *gfx)
{
assert(gfx);
return gfx->render_state.last_frame_time_us;
}
void gfx_fini(gfx_t *gfx)
{
assert(gfx);
IDirect3DDevice9_Release(gfx->ctx.device);
IDirect3D9_Release(gfx->ctx.d3d);
DestroyWindow(gfx->ctx.hwnd);
free(gfx);
}

View File

@@ -0,0 +1,59 @@
#ifndef D3D9_MONITOR_CHECK_GFX_H
#define D3D9_MONITOR_CHECK_GFX_H
#include <windows.h>
#include <d3d9.h>
#include <stdbool.h>
#include <stdint.h>
typedef struct gfx gfx_t;
struct IDirect3DDevice9;
typedef struct gfx_adapter_modes {
D3DDISPLAYMODE modes[1024];
uint32_t count;
} gfx_adapter_modes_t;
typedef struct gfx_info {
char adapter_identifier[1024];
uint32_t width;
uint32_t height;
uint32_t refresh_rate;
bool windowed;
bool vsync;
} gfx_info_t;
bool gfx_adapter_info_get(D3DADAPTER_IDENTIFIER9 *adapter);
bool gfx_adapter_modes_get(gfx_adapter_modes_t *modes);
bool gfx_init(uint32_t width,
uint32_t height,
uint32_t refresh_rate,
bool windowed,
bool vsync,
gfx_t **gfx);
uint32_t gfx_width_get(gfx_t *gfx);
uint32_t gfx_height_get(gfx_t *gfx);
bool gfx_info_get(gfx_t *gfx, gfx_info_t *info);
IDirect3DDevice9 *gfx_device_get(gfx_t *gfx);
bool gfx_frame_begin(gfx_t *gfx);
void gfx_frame_end(gfx_t *gfx);
uint64_t gfx_last_frame_count_get(gfx_t *gfx);
uint64_t gfx_last_frame_time_us_get(gfx_t *gfx);
bool gfx_adpater_info_get(gfx_t *gfx);
void gfx_fini(gfx_t *gfx);
#endif

View File

@@ -0,0 +1,90 @@
#include <windows.h>
#include <assert.h>
#include <stdbool.h>
#include <stdlib.h>
#include "util/mem.h"
typedef struct input_key_state {
bool previous_update_state;
bool current_update_state;
} input_key_state_t;
typedef struct input {
input_key_state_t esc;
input_key_state_t up;
input_key_state_t down;
input_key_state_t left;
input_key_state_t right;
input_key_state_t enter;
} input_t;
void input_init(input_t **input)
{
assert(input);
*input = xmalloc(sizeof(input_t));
memset(*input, 0, sizeof(input_t));
}
void input_update(input_t *input)
{
assert(input);
input->esc.previous_update_state = input->esc.current_update_state;
input->esc.current_update_state = GetAsyncKeyState(VK_ESCAPE) & 0x8000;
input->up.previous_update_state = input->up.current_update_state;
input->up.current_update_state = GetAsyncKeyState(VK_UP) & 0x8000;
input->down.previous_update_state = input->down.current_update_state;
input->down.current_update_state = GetAsyncKeyState(VK_DOWN) & 0x8000;
input->left.previous_update_state = input->left.current_update_state;
input->left.current_update_state = GetAsyncKeyState(VK_LEFT) & 0x8000;
input->right.previous_update_state = input->right.current_update_state;
input->right.current_update_state = GetAsyncKeyState(VK_RIGHT) & 0x8000;
input->enter.previous_update_state = input->enter.current_update_state;
input->enter.current_update_state = GetAsyncKeyState(VK_RETURN) & 0x8000;
}
bool input_key_esc_pushed(input_t *input)
{
return input->esc.previous_update_state == false && input->esc.current_update_state == true;
}
bool input_key_up_pushed(input_t *input)
{
return input->up.previous_update_state == false && input->up.current_update_state == true;
}
bool input_key_down_pushed(input_t *input)
{
return input->down.previous_update_state == false && input->down.current_update_state == true;
}
bool input_key_left_pushed(input_t *input)
{
return input->left.previous_update_state == false && input->left.current_update_state == true;
}
bool input_key_right_pushed(input_t *input)
{
return input->right.previous_update_state == false && input->right.current_update_state == true;
}
bool input_key_enter_pushed(input_t *input)
{
return input->enter.previous_update_state == false && input->enter.current_update_state == true;
}
void input_fini(input_t *input)
{
assert(input);
free(input);
}

View File

@@ -0,0 +1,26 @@
#ifndef D3D9_MONITOR_CHECK_INPUT_H
#define D3D9_MONITOR_CHECK_INPUT_H
#include <stdbool.h>
typedef struct input input_t;
void input_init(input_t **input);
void input_update(input_t *input);
bool input_key_esc_pushed(input_t *input);
bool input_key_up_pushed(input_t *input);
bool input_key_down_pushed(input_t *input);
bool input_key_left_pushed(input_t *input);
bool input_key_right_pushed(input_t *input);
bool input_key_enter_pushed(input_t *input);
void input_fini(input_t *input);
#endif

View File

@@ -0,0 +1,196 @@
#include <assert.h>
#include <stdbool.h>
#include <stdint.h>
#include "d3d9-monitor-check/gfx.h"
#include "d3d9-monitor-check/input.h"
#include "d3d9-monitor-check/menu.h"
#include "d3d9-monitor-check/print-console.h"
#include "d3d9-monitor-check/refresh-rate-test.h"
#include "d3d9-monitor-check/response-time-test.h"
#include "d3d9-monitor-check/vsync-test.h"
typedef enum INTERACTIVE_SCREEN {
INTERACTIVE_SCREEN_MENU = 0,
INTERACTIVE_SCREEN_REFRESH_RATE_TEST = 1,
INTERACTIVE_SCREEN_RESPONSE_TIME_TEST = 2,
INTERACTIVE_SCREEN_VSYNC_TEST = 3,
} interactive_screen_t;
static void _print_synopsis()
{
printfln_err("D3D9 monitor check tool interactive mode");
printfln_err("");
printfln_err("Usage:");
printfln_err(" d3d9-monitor-check interactive <width> <height> <refresh-rate> [--windowed] [--vsync-off]");
printfln_err("");
printfln_err(" width: Width of the rendering resolution to run the test at");
printfln_err(" height: Height of the rendering resolution to run the test at");
printfln_err(" refresh-rate: Target refresh rate to run the test at");
printfln_err(" windowed: Optional. Run the test in windowed mode (not recommended)");
printfln_err(" vsync-off: Optional. Run the test with vsync off (not recommended)");
}
static bool _interactive(
uint32_t width,
uint32_t height,
uint32_t refresh_rate,
bool windowed,
bool vsync)
{
gfx_t *gfx;
input_t *input;
bool loop_running;
interactive_screen_t current_screen;
menu_item_t selected_menu_item;
menu_t *menu;
refresh_rate_test_t *refresh_rate_test;
response_time_test_t *response_time_test;
vsync_test_t *vsync_test;
input_init(&input);
if (!gfx_init(width, height, refresh_rate, windowed, vsync, &gfx)) {
input_fini(input);
return false;
}
if (!menu_init(gfx, &menu)) {
gfx_fini(gfx);
input_fini(input);
return false;
}
loop_running = true;
current_screen = INTERACTIVE_SCREEN_MENU;
while (loop_running) {
input_update(input);
switch (current_screen) {
case INTERACTIVE_SCREEN_MENU:
if (input_key_esc_pushed(input)) {
loop_running = false;
break;
} else if (input_key_up_pushed(input)) {
menu_select_cursor_move_up(menu);
} else if (input_key_down_pushed(input)) {
menu_select_cursor_move_down(menu);
} else if (input_key_enter_pushed(input)) {
selected_menu_item = menu_item_selected_get(menu);
switch (selected_menu_item) {
case MENU_ITEM_REFRESH_RATE_TEST:
if (!refresh_rate_test_init(gfx, 600, 1200 ,&refresh_rate_test)) {
loop_running = false;
break;
}
current_screen = INTERACTIVE_SCREEN_REFRESH_RATE_TEST;
break;
case MENU_ITEM_RESPONSE_TIME_TEST:
if (!response_time_test_init(gfx, &response_time_test)) {
loop_running = false;
break;
}
current_screen = INTERACTIVE_SCREEN_RESPONSE_TIME_TEST;
break;
case MENU_ITEM_VSYNC_TEST:
if (!vsync_test_init(gfx, &vsync_test)) {
loop_running = false;
break;
}
current_screen = INTERACTIVE_SCREEN_VSYNC_TEST;
break;
case MENU_ITEM_EXIT:
loop_running = false;
break;
default:
assert(0);
break;
}
}
if (!menu_frame_update(menu)) {
loop_running = false;
break;
}
break;
case INTERACTIVE_SCREEN_REFRESH_RATE_TEST:
if ( input_key_esc_pushed(input) ||
!refresh_rate_test_frame_update(refresh_rate_test)) {
current_screen = INTERACTIVE_SCREEN_MENU;
refresh_rate_test_fini(refresh_rate_test);
}
break;
case INTERACTIVE_SCREEN_RESPONSE_TIME_TEST:
if ( input_key_esc_pushed(input) ||
!response_time_test_frame_update(response_time_test)) {
current_screen = INTERACTIVE_SCREEN_MENU;
response_time_test_fini(response_time_test);
}
break;
case INTERACTIVE_SCREEN_VSYNC_TEST:
if ( input_key_esc_pushed(input) ||
!vsync_test_frame_update(vsync_test)) {
current_screen = INTERACTIVE_SCREEN_MENU;
vsync_test_fini(vsync_test);
}
break;
}
}
menu_fini(menu);
gfx_fini(gfx);
input_fini(input);
return true;
}
bool interactive_main(int argc, char **argv)
{
uint32_t width;
uint32_t height;
uint32_t refresh_rate;
bool windowed;
bool vsync;
assert(argv);
if (argc < 3) {
_print_synopsis();
printfln_err("ERROR: Insufficient arguments");
return false;
}
width = atoi(argv[0]);
height = atoi(argv[1]);
refresh_rate = atoi(argv[2]);
windowed = false;
vsync = true;
for (int i = 3; i < argc; i++) {
if (!strcmp(argv[i], "--windowed")) {
windowed = true;
} else if (!strcmp(argv[i], "--vsync-off")) {
vsync = false;
}
}
return _interactive(width, height, refresh_rate, windowed, vsync);
}

View File

@@ -0,0 +1,8 @@
#ifndef D3D9_MONITOR_CHECK_INTERACTIVE_H
#define D3D9_MONITOR_CHECK_INTERACTIVE_H
#include <stdbool.h>
bool interactive_main(int argc, char **argv);
#endif

View File

@@ -0,0 +1,41 @@
#include <string.h>
#include "d3d9-monitor-check/cmdline.h"
#include "d3d9-monitor-check/interactive.h"
#include "d3d9-monitor-check/print-console.h"
static void _print_synopsis()
{
printfln_err("D3D9 monitor check tool");
printfln_err("");
printfln_err("A versatile tool for running various (music game relevant) monitor tests using the D3D9 rendering API");
printfln_err("");
printfln_err("Available commands:");
printfln_err(" cmdline: Run the tool in command line mode");
printfln_err(" interactive: Run the tool in interactive mode");
}
int main(int argc, char **argv)
{
const char *command;
bool success;
if (argc < 2) {
_print_synopsis();
printfln_err("ERROR: Insufficient arguments");
return 1;
}
command = argv[1];
if (!strcmp(command, "cmdline")) {
success = cmdline_main(argc - 2, argv + 2);
} else if (!strcmp(command, "interactive")) {
success = interactive_main(argc - 2, argv + 2);
} else {
_print_synopsis();
success = false;
}
return success ? 0 : 1;
}

View File

@@ -0,0 +1,114 @@
#include <assert.h>
#include "d3d9-monitor-check/gfx.h"
#include "d3d9-monitor-check/font.h"
#include "d3d9-monitor-check/menu.h"
#include "util/mem.h"
typedef struct menu {
gfx_t *gfx;
font_t *font;
menu_item_t current_selected_item;
} menu_t;
bool menu_init(
gfx_t *gfx,
menu_t **menu)
{
assert(gfx);
assert(menu);
*menu = xmalloc(sizeof(menu_t));
(*menu)->gfx = gfx;
(*menu)->current_selected_item = MENU_ITEM_REFRESH_RATE_TEST;
if (!font_init(gfx, 20, &(*menu)->font)) {
free(*menu);
return false;
}
return true;
}
void menu_select_cursor_move_up(menu_t *menu)
{
assert(menu);
if (menu->current_selected_item == MENU_ITEM_REFRESH_RATE_TEST) {
menu->current_selected_item = MENU_ITEM_EXIT;
} else {
menu->current_selected_item--;
}
}
void menu_select_cursor_move_down(menu_t *menu)
{
assert(menu);
if (menu->current_selected_item == MENU_ITEM_EXIT) {
menu->current_selected_item = MENU_ITEM_REFRESH_RATE_TEST;
} else {
menu->current_selected_item++;
}
}
menu_item_t menu_item_selected_get(menu_t *menu)
{
assert(menu);
return menu->current_selected_item;
}
bool menu_frame_update(menu_t *menu)
{
font_text_t text;
assert(menu);
if (!gfx_frame_begin(menu->gfx)) {
return false;
}
font_text_begin(menu->font, 10, 10, 10, &text);
font_text_white_draw(&text, "D3D9 Monitor Check - Main Menu");
font_text_newline(&text);
font_text_newline(&text);
if (menu->current_selected_item == MENU_ITEM_REFRESH_RATE_TEST) {
font_text_white_draw(&text, "-> 1. Refresh Rate Test");
} else {
font_text_white_draw(&text, " 1. Refresh Rate Test");
}
font_text_newline(&text);
if (menu->current_selected_item == MENU_ITEM_RESPONSE_TIME_TEST) {
font_text_white_draw(&text, "-> 2. Response Time Test");
} else {
font_text_white_draw(&text, " 2. Response Time Test");
}
font_text_newline(&text);
if (menu->current_selected_item == MENU_ITEM_VSYNC_TEST) {
font_text_white_draw(&text, "-> 3. VSync Test");
} else {
font_text_white_draw(&text, " 3. VSync Test");
}
font_text_newline(&text);
if (menu->current_selected_item == MENU_ITEM_EXIT) {
font_text_white_draw(&text, "-> 4. Exit");
} else {
font_text_white_draw(&text, " 4. Exit");
}
font_text_end(&text);
gfx_frame_end(menu->gfx);
return true;
}
void menu_fini(menu_t *menu)
{
assert(menu);
font_fini(menu->font);
free(menu);
}

View File

@@ -0,0 +1,32 @@
#ifndef D3D9_MONITOR_CHECK_MENU_H
#define D3D9_MONITOR_CHECK_MENU_H
#include <stdbool.h>
#include <stdint.h>
#include "d3d9-monitor-check/gfx.h"
typedef enum MENU_ITEM {
MENU_ITEM_REFRESH_RATE_TEST = 0,
MENU_ITEM_RESPONSE_TIME_TEST = 1,
MENU_ITEM_VSYNC_TEST = 2,
MENU_ITEM_EXIT = 3,
} menu_item_t;
typedef struct menu menu_t;
bool menu_init(
gfx_t *gfx,
menu_t **menu);
void menu_select_cursor_move_up(menu_t *menu);
void menu_select_cursor_move_down(menu_t *menu);
menu_item_t menu_item_selected_get(menu_t *menu);
bool menu_frame_update(menu_t *menu);
void menu_fini(menu_t *menu);
#endif

View File

@@ -0,0 +1,22 @@
#ifndef PRINT_CONSOLE_H
#define PRINT_CONSOLE_H
#include <stdio.h>
#include "util/winerr.h"
#define printf_out(fmt, ...) \
fprintf(stdout, fmt, ##__VA_ARGS__)
#define printf_err(fmt, ...) \
fprintf(stderr, fmt, ##__VA_ARGS__)
#define printfln_out(fmt, ...) \
fprintf(stdout, fmt "\n", ##__VA_ARGS__)
#define printfln_err(fmt, ...) \
fprintf(stderr, fmt "\n", ##__VA_ARGS__)
#define printfln_winerr(fmt, ...) \
char *winerr = util_winerr_format_last_error_code(); \
fprintf(stderr, fmt ": %s\n", ##__VA_ARGS__, winerr); \
free(winerr);
#endif

View File

@@ -0,0 +1,304 @@
#include <assert.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include "d3d9-monitor-check/gfx.h"
#include "d3d9-monitor-check/font.h"
#include "d3d9-monitor-check/refresh-rate-test.h"
#include "util/mem.h"
typedef enum refresh_rate_test_phase {
REFRESH_RATE_TEST_PHASE_WARM_UP = 0,
REFRESH_RATE_TEST_PHASE_MEASURE = 1,
REFRESH_RATE_TEST_PHASE_DONE = 2
} refresh_rate_test_phase_t;
typedef struct refresh_rate_test_ctx {
gfx_t *gfx;
font_t *font;
uint32_t total_warm_up_frame_count;
uint32_t total_sample_frame_count;
} refresh_rate_test_ctx_t;
typedef struct refresh_rate_test_state {
gfx_info_t gfx_info;
refresh_rate_test_phase_t phase;
uint64_t last_frame_time_us;
uint32_t warm_up_frame_count;
uint32_t sample_frame_count;
uint64_t warm_up_elapsed_us;
uint64_t sample_elapsed_us;
} refresh_rate_test_state_t;
typedef struct refresh_rate_test {
refresh_rate_test_ctx_t ctx;
refresh_rate_test_state_t state;
} refresh_rate_test_t;
static refresh_rate_test_phase_t _refresh_rate_test_phase_evaluate(const refresh_rate_test_t *test)
{
switch (test->state.phase) {
case REFRESH_RATE_TEST_PHASE_WARM_UP:
if (test->state.warm_up_frame_count < test->ctx.total_warm_up_frame_count) {
return REFRESH_RATE_TEST_PHASE_WARM_UP;
} else {
return REFRESH_RATE_TEST_PHASE_MEASURE;
}
case REFRESH_RATE_TEST_PHASE_MEASURE:
if (test->state.sample_frame_count < test->ctx.total_sample_frame_count) {
return REFRESH_RATE_TEST_PHASE_MEASURE;
} else {
return REFRESH_RATE_TEST_PHASE_DONE;
}
case REFRESH_RATE_TEST_PHASE_DONE:
return REFRESH_RATE_TEST_PHASE_DONE;
default:
assert(0);
return REFRESH_RATE_TEST_PHASE_DONE;
}
}
bool refresh_rate_test_init(
gfx_t *gfx,
uint32_t total_warm_up_frame_count,
uint32_t total_sample_frame_count,
refresh_rate_test_t **test)
{
assert(gfx);
assert(test);
*test = xmalloc(sizeof(refresh_rate_test_t));
memset(*test, 0, sizeof(refresh_rate_test_t));
if (!font_init(gfx, 20, &(*test)->ctx.font)) {
free(*test);
return false;
}
font_init(gfx, 20, &(*test)->ctx.font);
(*test)->ctx.gfx = gfx;
(*test)->ctx.total_warm_up_frame_count = total_warm_up_frame_count;
(*test)->ctx.total_sample_frame_count = total_sample_frame_count;
(*test)->state.phase = REFRESH_RATE_TEST_PHASE_WARM_UP;
(*test)->state.last_frame_time_us = 0;
(*test)->state.warm_up_frame_count = 0;
(*test)->state.sample_frame_count = 0;
(*test)->state.warm_up_elapsed_us = 0;
(*test)->state.sample_elapsed_us = 0;
gfx_info_get(gfx, &(*test)->state.gfx_info);
return true;
}
static bool _refresh_rate_test_phase_warm_up_frame_update(refresh_rate_test_t *test)
{
font_text_t text;
assert(test);
if (!gfx_frame_begin(test->ctx.gfx)) {
return false;
}
font_text_begin(test->ctx.font, 0, 10, 10, &text);
font_text_white_draw(&text, "Refresh Rate Test");
font_text_newline(&text);
font_text_white_draw(&text, "GPU: %s", test->state.gfx_info.adapter_identifier);
font_text_newline(&text);
font_text_white_draw(&text, "Spec: %d x %d @ %d hz, %s, vsync %s", test->state.gfx_info.width, test->state.gfx_info.height, test->state.gfx_info.refresh_rate,
test->state.gfx_info.windowed ? "windowed" : "fullscreen", test->state.gfx_info.vsync ? "on" : "off");
font_text_newline(&text);
font_text_newline(&text);
// First frame won't have any data available causing division by zero in the stats
if (test->state.warm_up_frame_count != 0) {
font_text_white_draw(&text, "Status: Warm-up in progress ...");
font_text_newline(&text);
font_text_white_draw(&text, "Frame: %d / %d", test->state.warm_up_frame_count, test->ctx.total_warm_up_frame_count);
font_text_newline(&text);
font_text_white_draw(&text, "Last frame time: %.3f ms", test->state.last_frame_time_us / 1000.0f);
font_text_newline(&text);
font_text_white_draw(&text, "Avg frame time: %.3f ms", test->state.warm_up_elapsed_us / test->state.warm_up_frame_count / 1000.0f);
font_text_newline(&text);
font_text_white_draw(&text, "Last refresh rate: %.3f Hz", 1000.0f / (test->state.last_frame_time_us / 1000.0f));
font_text_newline(&text);
font_text_white_draw(&text, "Avg refresh rate: %.3f Hz", 1000.0f / (test->state.warm_up_elapsed_us / test->state.warm_up_frame_count / 1000.0f));
font_text_newline(&text);
}
font_text_newline(&text);
font_text_white_draw(&text, "Press ESC to exit early");
font_text_end(&text);
gfx_frame_end(test->ctx.gfx);
test->state.last_frame_time_us = gfx_last_frame_time_us_get(test->ctx.gfx);
test->state.warm_up_elapsed_us += test->state.last_frame_time_us;
test->state.warm_up_frame_count++;
return true;
}
static bool _refresh_rate_test_phase_measure_frame_update(refresh_rate_test_t *test)
{
font_text_t text;
assert(test);
if (!gfx_frame_begin(test->ctx.gfx)) {
return false;
}
font_text_begin(test->ctx.font, 0, 10, 10, &text);
font_text_white_draw(&text, "Refresh Rate Test");
font_text_newline(&text);
font_text_white_draw(&text, "GPU: %s", test->state.gfx_info.adapter_identifier);
font_text_newline(&text);
font_text_white_draw(&text, "Spec: %d x %d @ %d hz, %s, vsync %s", test->state.gfx_info.width, test->state.gfx_info.height, test->state.gfx_info.refresh_rate,
test->state.gfx_info.windowed ? "windowed" : "fullscreen", test->state.gfx_info.vsync ? "on" : "off");
font_text_newline(&text);
font_text_newline(&text);
// First frame won't have any data available causing division by zero in the stats
if (test->state.sample_frame_count != 0) {
font_text_white_draw(&text, "Status: Measuring in progress ...");
font_text_newline(&text);
font_text_white_draw(&text, "Frame: %d / %d", test->state.sample_frame_count, test->ctx.total_sample_frame_count);
font_text_newline(&text);
font_text_white_draw(&text, "Last frame time: %.3f ms", test->state.last_frame_time_us / 1000.0f);
font_text_newline(&text);
font_text_white_draw(&text, "Avg frame time: %.3f ms", test->state.sample_elapsed_us / test->state.sample_frame_count / 1000.0f);
font_text_newline(&text);
font_text_white_draw(&text, "Last refresh rate: %.3f Hz", 1000.0f / (test->state.last_frame_time_us / 1000.0f));
font_text_newline(&text);
font_text_white_draw(&text, "Avg refresh rate: %.3f Hz", 1000.0f / (test->state.sample_elapsed_us / test->state.sample_frame_count / 1000.0f));
font_text_newline(&text);
}
font_text_newline(&text);
font_text_white_draw(&text, "Press ESC to exit early");
font_text_end(&text);
gfx_frame_end(test->ctx.gfx);
test->state.last_frame_time_us = gfx_last_frame_time_us_get(test->ctx.gfx);
test->state.sample_elapsed_us += test->state.last_frame_time_us;
test->state.sample_frame_count++;
return true;
}
bool refresh_rate_test_frame_update(refresh_rate_test_t *test)
{
assert(test);
test->state.phase = _refresh_rate_test_phase_evaluate(test);
switch (test->state.phase) {
case REFRESH_RATE_TEST_PHASE_WARM_UP:
return _refresh_rate_test_phase_warm_up_frame_update(test);
case REFRESH_RATE_TEST_PHASE_MEASURE:
return _refresh_rate_test_phase_measure_frame_update(test);
case REFRESH_RATE_TEST_PHASE_DONE:
return false;
default:
assert(0);
return false;
}
}
void refresh_rate_test_results_get(const refresh_rate_test_t *test, refresh_rate_test_results_t *results)
{
assert(test);
assert(results);
results->total_warm_up_frame_count = test->state.warm_up_frame_count;
results->total_sample_frame_count = test->state.sample_frame_count;
if (test->state.sample_elapsed_us > 0 && test->state.sample_frame_count > 0) {
results->avg_frame_time_ms = test->state.sample_elapsed_us / test->state.sample_frame_count / 1000.0f;
results->avg_refresh_rate_hz = 1000.0f / results->avg_frame_time_ms;
} else {
results->avg_frame_time_ms = 0;
results->avg_refresh_rate_hz = 0;
}
}
bool refresh_rate_test_results_frame_update(refresh_rate_test_t *test, uint32_t results_timeout_seconds)
{
refresh_rate_test_results_t results;
font_text_t text;
assert(test);
if (!gfx_frame_begin(test->ctx.gfx)) {
return false;
}
refresh_rate_test_results_get(test, &results);
font_text_begin(test->ctx.font, 0, 10, 10, &text);
font_text_white_draw(&text, "Refresh Rate Test");
font_text_newline(&text);
font_text_white_draw(&text, "GPU: %s", test->state.gfx_info.adapter_identifier);
font_text_newline(&text);
font_text_white_draw(&text, "Spec: %d x %d @ %d hz, %s, vsync %s", test->state.gfx_info.width, test->state.gfx_info.height, test->state.gfx_info.refresh_rate,
test->state.gfx_info.windowed ? "windowed" : "fullscreen", test->state.gfx_info.vsync ? "on" : "off");
font_text_newline(&text);
font_text_newline(&text);
if (test->ctx.total_warm_up_frame_count != test->state.warm_up_frame_count ||
test->ctx.total_sample_frame_count != test->state.sample_frame_count) {
font_text_white_draw(&text, "Status: Warning, exited early");
} else {
font_text_white_draw(&text, "Status: Completed");
}
font_text_newline(&text);
font_text_white_draw(&text, "Total warm-up frame count: %d", results.total_warm_up_frame_count);
font_text_newline(&text);
font_text_white_draw(&text, "Total sample frame count: %d", results.total_sample_frame_count);
font_text_newline(&text);
font_text_white_draw(&text, "Avg frame time: %.3f ms", results.avg_frame_time_ms);
font_text_newline(&text);
font_text_white_draw(&text, "Avg refresh rate: %.3f Hz", results.avg_refresh_rate_hz);
font_text_newline(&text);
font_text_newline(&text);
font_text_white_draw(&text, "Exiting in %d seconds ...", results_timeout_seconds);
font_text_newline(&text);
font_text_white_draw(&text, "Press ESC to exit immediately");
font_text_end(&text);
gfx_frame_end(test->ctx.gfx);
return true;
}
void refresh_rate_test_fini(refresh_rate_test_t *test)
{
assert(test);
font_fini(test->ctx.font);
free(test);
}

Some files were not shown because too many files have changed in this diff Show More