From f1bd70ef294bdb31916602cd06ee69d01299b778 Mon Sep 17 00:00:00 2001 From: Nam Nguyen Date: Sat, 19 Jul 2025 06:42:07 +0700 Subject: [PATCH] Add Python sample for 3D features (AFMF, RSR...) --- Samples/python/3D/3D.py | 103 +++ .../ADLXPybind/ADLXPybind/ADLXPybind.vcxproj | 18 +- Samples/python/ADLXPybind/ADLXPybind/bind.cpp | 834 +++++++++++++++++- 3 files changed, 942 insertions(+), 13 deletions(-) create mode 100644 Samples/python/3D/3D.py diff --git a/Samples/python/3D/3D.py b/Samples/python/3D/3D.py new file mode 100644 index 00000000..30955ef7 --- /dev/null +++ b/Samples/python/3D/3D.py @@ -0,0 +1,103 @@ +# + +import ADLXPybind as ADLX + +# Iterate display and display event:plug and unplug the display +def afmfDemo(): + # Get ADLXHelp and ADLX initialization + adlxHelper = ADLX.ADLXHelper() + ret = adlxHelper.Initialize() + + if ret == ADLX.ADLX_RESULT.ADLX_OK: + # Get system services + system = adlxHelper.GetSystemServices() + + if system is not None: + # Get display services + displayService = system.GetDisplaysServices() + if displayService is not None: + count = displayService.GetNumberOfDisplays() + print("display count: {}".format(count)) + disList = displayService.GetDisplays() + if disList is not None: + foundDisplay = False + for index, display in enumerate(disList): + if display is not None and not foundDisplay: + foundDisplay = True + gpu = display.GetGPU() + gpuName = gpu.name() + vendorId = gpu.vendorId() + print(f"gpu name: {gpuName} vendor id: {vendorId}") + threeDSettingsServices = system.Get3DSettingsServices() + + # AntiLag + antiLag = threeDSettingsServices.GetAntiLag(gpu) + antiLagSupported = antiLag.IsSupported() + antiLagEnabled = antiLag.IsEnabled() + print(f"support antilag: {antiLagSupported}, enable antilag: {antiLagEnabled}") + # antiLag.SetEnabled(False) + + # Chill + chill = threeDSettingsServices.GetChill(gpu) + chillSupported = chill.IsSupported() + chillEnabled = chill.IsEnabled() + minFPS = chill.GetMinFPS() + maxFPS = chill.GetMaxFPS() + print(f"support chill: {chillSupported}, enable chill: {chillEnabled} minFPS: {minFPS} maxFPS: {maxFPS}") + # if not chillEnabled: + # chill.SetEnabled(True) + # chill.SetMinFPS(30) + # chill.SetMaxFPS(60) + + # Boost + boost = threeDSettingsServices.GetBoost(gpu) + boostSupported = boost.IsSupported() + boostEnabled = boost.IsEnabled() + boostResolution = boost.GetResolution() # Performance: 50, Quality: 84 + # boost.SetEnabled(True) + print(f"support boost: {boostSupported}, enable boost: {boostEnabled} boost resolution: {boostResolution}") + + # GPU Scaling + gpuScaling = displayService.GetGPUScaling(display) + gpuScalingSupported = gpuScaling.IsSupported() + gpuScalingEnabled = gpuScaling.IsEnabled() + print(f"support GPU scaling: {gpuScalingSupported}, enable GPU scaling: {gpuScalingEnabled}") + # gpuScaling.SetEnabled(True) + + # Integer Scaling + integerScaling = displayService.GetIntegerScaling(display) + integerScalingSupported = integerScaling.IsSupported() + integerScalingEnabled = integerScaling.IsEnabled() + print(f"support integer scaling: {integerScalingSupported}, enable integer scaling: {integerScalingEnabled}") + + # Scaling Mode + scalingMode = displayService.GetScalingMode(display) + scalingModeSupported = scalingMode.IsSupported() + scalingModeNow = scalingMode.GetMode() + print(f"support scaling mode: {scalingModeSupported}, scaling mode: {scalingModeNow}") + + # Radeon Super Resolution + radeonSuperResolution = threeDSettingsServices.GetRadeonSuperResolution() + radeonSuperResolutionSupported = radeonSuperResolution.IsSupported() + radeonSuperResolutionEnabled = radeonSuperResolution.IsEnabled() + radeonSuperResolutionSharpness = radeonSuperResolution.GetSharpness() + print(f"support radeon super resolution: {radeonSuperResolutionSupported}, enabled: {radeonSuperResolutionEnabled}, sharpness: {radeonSuperResolutionSharpness}") + # radeonSuperResolution.SetEnabled(False) + + # AMD Fluid Motion Frame + threeDSettingsServices1 = system.Get3DSettingsServices1() + amdFluidMotionFrame = threeDSettingsServices1.GetAMDFluidMotionFrame() + amdFluidMotionFrameSupported = amdFluidMotionFrame.IsSupported() + amdFluidMotionFrameEnabled = amdFluidMotionFrame.IsEnabled() + print(f"support AMD fluid motion frame: {amdFluidMotionFrameSupported}, enabled: {amdFluidMotionFrameEnabled}") + # amdFluidMotionFrame.SetEnabled(True) + + # Terminate ADLX + ret = adlxHelper.Terminate() + print("ADLX Terminate ret is: {}".format(ret)) + +afmfDemo() \ No newline at end of file diff --git a/Samples/python/ADLXPybind/ADLXPybind/ADLXPybind.vcxproj b/Samples/python/ADLXPybind/ADLXPybind/ADLXPybind.vcxproj index 89dd6e82..ac5b4685 100644 --- a/Samples/python/ADLXPybind/ADLXPybind/ADLXPybind.vcxproj +++ b/Samples/python/ADLXPybind/ADLXPybind/ADLXPybind.vcxproj @@ -29,26 +29,26 @@ DynamicLibrary true - v142 + v143 Unicode DynamicLibrary false - v142 + v143 true Unicode DynamicLibrary true - v142 + v143 Unicode DynamicLibrary false - v142 + v143 true Unicode @@ -118,11 +118,12 @@ Windows true false - python39.lib;%(AdditionalDependencies) + python311.lib;%(AdditionalDependencies) copy /Y "$(TargetDir)$(ProjectName).pyd" "$(SolutionDir)..\DisplayEvents\$(ProjectName).pyd" -copy /Y "$(TargetDir)$(ProjectName).pyd" "$(SolutionDir)..\DisplayInfo\$(ProjectName).pyd" +copy /Y "$(TargetDir)$(ProjectName).pyd" "$(SolutionDir)..\DisplayInfo\$(ProjectName).pyd" +copy /Y "$(TargetDir)$(ProjectName).pyd" "$(SolutionDir)..\3D\$(ProjectName).pyd" @@ -163,11 +164,12 @@ copy /Y "$(TargetDir)$(ProjectName).pyd" "$(SolutionDir)..\DisplayInfo\$(Project true true false - python39.lib;%(AdditionalDependencies) + python311.lib;%(AdditionalDependencies) copy /Y "$(TargetDir)$(ProjectName).pyd" ""$(SolutionDir)..\DisplayEvents\$(ProjectName).pyd" -copy /Y "$(TargetDir)$(ProjectName).pyd" ""$(SolutionDir)..\DisplayInfo\$(ProjectName).pyd" +copy /Y "$(TargetDir)$(ProjectName).pyd" ""$(SolutionDir)..\DisplayInfo\$(ProjectName).pyd" +copy /Y "$(TargetDir)$(ProjectName).pyd" ""$(SolutionDir)..\3D\$(ProjectName).pyd" diff --git a/Samples/python/ADLXPybind/ADLXPybind/bind.cpp b/Samples/python/ADLXPybind/ADLXPybind/bind.cpp index 3037599d..7ea74d37 100644 --- a/Samples/python/ADLXPybind/ADLXPybind/bind.cpp +++ b/Samples/python/ADLXPybind/ADLXPybind/bind.cpp @@ -13,6 +13,10 @@ // Include SDK depends #include "../../../../SDK/ADLXHelper/Windows/Cpp/ADLXHelper.h" #include "../../../../SDK/Include/IDisplays.h" +#include "../../../../SDK/Include/I3DSettings.h" +#include "../../../../SDK/Include/ISystem.h" +#include "../../../../SDK/Include/IDisplaySettings.h" +#include "../../../../SDK/Include/I3DSettings1.h" namespace py = pybind11; using namespace adlx; @@ -218,6 +222,362 @@ class PyDisplayService : public IADLXDisplayServices } }; +class PyGPU : public IADLXGPU +{ +public: + using IADLXGPU::IADLXGPU; + + adlx_long Acquire() override { + PYBIND11_OVERRIDE_PURE(adlx_long, IADLXInterface, Acquire); + } + + adlx_long Release() override { + PYBIND11_OVERRIDE_PURE(adlx_long, IADLXInterface, Release); + } + + ADLX_RESULT QueryInterface(const wchar_t* interfaceId, void** ppInterface) { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLXInterface, QueryInterface); + } + + ADLX_RESULT VendorId(const char** vendorId) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLXGPU, VendorId); + } + + ADLX_RESULT ASICFamilyType(ADLX_ASIC_FAMILY_TYPE* asicFamilyType) const override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLXGPU, ASICFamilyType); + } + + ADLX_RESULT Type(ADLX_GPU_TYPE* gpuType) const override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLXGPU, Type); + } + + ADLX_RESULT IsExternal(adlx_bool* isExternal) const override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLXGPU, IsExternal); + } + + ADLX_RESULT Name(const char** displayName) const override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLXGPU, Name); + } + + ADLX_RESULT DriverPath(const char** driverPath) const override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLXGPU, DriverPath); + } + + ADLX_RESULT PNPString(const char** pnpString) const override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLXGPU, PNPString); + } + + ADLX_RESULT HasDesktops(adlx_bool* hasDesktops) const override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLXGPU, HasDesktops); + } + + ADLX_RESULT TotalVRAM(adlx_uint* vramMB) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLXGPU, TotalVRAM); + } + + ADLX_RESULT VRAMType(const char** type) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLXGPU, VRAMType); + } + + ADLX_RESULT BIOSInfo(const char** partNumber, const char** version, const char** date) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLXGPU, BIOSInfo); + } + + ADLX_RESULT DeviceId(const char** deviceId) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLXGPU, DeviceId); + } + + ADLX_RESULT RevisionId(const char** revisionId) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLXGPU, RevisionId); + } + + ADLX_RESULT SubSystemId(const char** subSystemId) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLXGPU, SubSystemId); + } + + ADLX_RESULT SubSystemVendorId(const char** subSystemVendorId) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLXGPU, SubSystemVendorId); + } + + ADLX_RESULT UniqueId(adlx_int* uniqueId) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLXGPU, UniqueId); + } +}; + +class Py3DAntiLag : public IADLX3DAntiLag +{ +public: + using IADLX3DAntiLag::IADLX3DAntiLag; + + adlx_long Acquire() override { + PYBIND11_OVERRIDE_PURE(adlx_long, IADLXInterface, Acquire); + } + + adlx_long Release() override { + PYBIND11_OVERRIDE_PURE(adlx_long, IADLXInterface, Release); + } + + ADLX_RESULT QueryInterface(const wchar_t* interfaceId, void** ppInterface) { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLXInterface, QueryInterface); + } + + ADLX_RESULT IsSupported(adlx_bool* supported) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DAntiLag, IsSupported); + } + + ADLX_RESULT IsEnabled(adlx_bool* enabled) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DAntiLag, IsEnabled); + } + + ADLX_RESULT SetEnabled(adlx_bool enable) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DAntiLag, SetEnabled); + } +}; + +class Py3DChill : public IADLX3DChill +{ +public: + using IADLX3DChill::IADLX3DChill; + + adlx_long Acquire() override { + PYBIND11_OVERRIDE_PURE(adlx_long, IADLXInterface, Acquire); + } + + adlx_long Release() override { + PYBIND11_OVERRIDE_PURE(adlx_long, IADLXInterface, Release); + } + + ADLX_RESULT QueryInterface(const wchar_t* interfaceId, void** ppInterface) { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLXInterface, QueryInterface); + } + + ADLX_RESULT IsSupported(adlx_bool* supported) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DChill, IsSupported); + } + + ADLX_RESULT IsEnabled(adlx_bool* enabled) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DChill, IsEnabled); + } + + ADLX_RESULT GetFPSRange(ADLX_IntRange* range) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DChill, GetFPSRange); + } + + ADLX_RESULT GetMinFPS(adlx_int* currentMinFPS) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DChill, GetMinFPS); + } + + ADLX_RESULT GetMaxFPS(adlx_int* currentMaxFPS) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DChill, GetMaxFPS); + } + + ADLX_RESULT SetEnabled(adlx_bool enable) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DChill, SetEnabled); + } + + ADLX_RESULT SetMinFPS(adlx_int minFPS) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DChill, SetMinFPS); + } + + ADLX_RESULT SetMaxFPS(adlx_int maxFPS) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DChill, SetMaxFPS); + } +}; + +class Py3DBoost : public IADLX3DBoost +{ +public: + using IADLX3DBoost::IADLX3DBoost; + + adlx_long Acquire() override { + PYBIND11_OVERRIDE_PURE(adlx_long, IADLXInterface, Acquire); + } + + adlx_long Release() override { + PYBIND11_OVERRIDE_PURE(adlx_long, IADLXInterface, Release); + } + + ADLX_RESULT QueryInterface(const wchar_t* interfaceId, void** ppInterface) { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLXInterface, QueryInterface); + } + + ADLX_RESULT IsSupported(adlx_bool* supported) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DBoost, IsSupported); + } + + ADLX_RESULT IsEnabled(adlx_bool* enabled) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DBoost, IsEnabled); + } + + ADLX_RESULT GetResolutionRange(ADLX_IntRange* range) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DBoost, GetResolutionRange); + } + + ADLX_RESULT GetResolution(adlx_int* currentMinRes) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DBoost, GetResolution); + } + + ADLX_RESULT SetEnabled(adlx_bool enable) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DBoost, SetEnabled); + } + + ADLX_RESULT SetResolution(adlx_int minRes) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DBoost, SetResolution); + } +}; + +class Py3DSettingsServices : public IADLX3DSettingsServices +{ +public: + using IADLX3DSettingsServices::IADLX3DSettingsServices; + + adlx_long Acquire() override { + PYBIND11_OVERRIDE_PURE(adlx_long, IADLXInterface, Acquire); + } + + adlx_long Release() override { + PYBIND11_OVERRIDE_PURE(adlx_long, IADLXInterface, Release); + } + + ADLX_RESULT QueryInterface(const wchar_t* interfaceId, void** ppInterface) { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLXInterface, QueryInterface); + } + + ADLX_RESULT GetAntiLag(IADLXGPU* pGPU, IADLX3DAntiLag** pp3DAntiLag) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DSettingsServices, GetAntiLag); + } + + ADLX_RESULT GetChill(IADLXGPU* pGPU, IADLX3DChill** pp3DChill) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DSettingsServices, GetChill); + } + + ADLX_RESULT GetBoost(IADLXGPU* pGPU, IADLX3DBoost** pp3DBoost) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DSettingsServices, GetBoost); + } + + ADLX_RESULT GetImageSharpening(IADLXGPU* pGPU, IADLX3DImageSharpening** pp3DImageSharpening) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DSettingsServices, GetImageSharpening); + } + + ADLX_RESULT GetEnhancedSync(IADLXGPU* pGPU, IADLX3DEnhancedSync** pp3DEnhancedSync) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DSettingsServices, GetEnhancedSync); + } + + ADLX_RESULT GetWaitForVerticalRefresh(IADLXGPU* pGPU, IADLX3DWaitForVerticalRefresh** pp3DWaitForVerticalRefresh) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DSettingsServices, GetWaitForVerticalRefresh); + } + + ADLX_RESULT GetFrameRateTargetControl(IADLXGPU* pGPU, IADLX3DFrameRateTargetControl** pp3DFrameRateTargetControl) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DSettingsServices, GetFrameRateTargetControl); + } + + ADLX_RESULT GetAntiAliasing(IADLXGPU* pGPU, IADLX3DAntiAliasing** pp3DAntiAliasing) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DSettingsServices, GetAntiAliasing); + } + + ADLX_RESULT GetMorphologicalAntiAliasing(IADLXGPU* pGPU, IADLX3DMorphologicalAntiAliasing** pp3DMorphologicalAntiAliasing) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DSettingsServices, GetMorphologicalAntiAliasing); + } + + ADLX_RESULT GetAnisotropicFiltering(IADLXGPU* pGPU, IADLX3DAnisotropicFiltering** pp3DAnisotropicFiltering) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DSettingsServices, GetAnisotropicFiltering); + } + + ADLX_RESULT GetTessellation(IADLXGPU* pGPU, IADLX3DTessellation** pp3DTessellation) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DSettingsServices, GetTessellation); + } + + ADLX_RESULT GetRadeonSuperResolution(IADLX3DRadeonSuperResolution** pp3DRadeonSuperResolution) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DSettingsServices, GetRadeonSuperResolution); + } + + ADLX_RESULT GetResetShaderCache(IADLXGPU* pGPU, IADLX3DResetShaderCache** pp3DResetShaderCache) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DSettingsServices, GetResetShaderCache); + } + + ADLX_RESULT Get3DSettingsChangedHandling(IADLX3DSettingsChangedHandling** pp3DSettingsChangedHandling) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DSettingsServices, Get3DSettingsChangedHandling); + } +}; + +class Py3DSettingsServices1 : public IADLX3DSettingsServices1 +{ +public: + using IADLX3DSettingsServices1::IADLX3DSettingsServices1; + + adlx_long Acquire() override { + PYBIND11_OVERRIDE_PURE(adlx_long, IADLXInterface, Acquire); + } + + adlx_long Release() override { + PYBIND11_OVERRIDE_PURE(adlx_long, IADLXInterface, Release); + } + + ADLX_RESULT QueryInterface(const wchar_t* interfaceId, void** ppInterface) { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLXInterface, QueryInterface); + } + + ADLX_RESULT GetAntiLag(IADLXGPU* pGPU, IADLX3DAntiLag** pp3DAntiLag) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DSettingsServices1, GetAntiLag); + } + + ADLX_RESULT GetChill(IADLXGPU* pGPU, IADLX3DChill** pp3DChill) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DSettingsServices1, GetChill); + } + + ADLX_RESULT GetBoost(IADLXGPU* pGPU, IADLX3DBoost** pp3DBoost) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DSettingsServices1, GetBoost); + } + + ADLX_RESULT GetImageSharpening(IADLXGPU* pGPU, IADLX3DImageSharpening** pp3DImageSharpening) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DSettingsServices1, GetImageSharpening); + } + + ADLX_RESULT GetEnhancedSync(IADLXGPU* pGPU, IADLX3DEnhancedSync** pp3DEnhancedSync) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DSettingsServices1, GetEnhancedSync); + } + + ADLX_RESULT GetWaitForVerticalRefresh(IADLXGPU* pGPU, IADLX3DWaitForVerticalRefresh** pp3DWaitForVerticalRefresh) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DSettingsServices1, GetWaitForVerticalRefresh); + } + + ADLX_RESULT GetFrameRateTargetControl(IADLXGPU* pGPU, IADLX3DFrameRateTargetControl** pp3DFrameRateTargetControl) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DSettingsServices1, GetFrameRateTargetControl); + } + + ADLX_RESULT GetAntiAliasing(IADLXGPU* pGPU, IADLX3DAntiAliasing** pp3DAntiAliasing) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DSettingsServices1, GetAntiAliasing); + } + + ADLX_RESULT GetMorphologicalAntiAliasing(IADLXGPU* pGPU, IADLX3DMorphologicalAntiAliasing** pp3DMorphologicalAntiAliasing) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DSettingsServices1, GetMorphologicalAntiAliasing); + } + + ADLX_RESULT GetAnisotropicFiltering(IADLXGPU* pGPU, IADLX3DAnisotropicFiltering** pp3DAnisotropicFiltering) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DSettingsServices1, GetAnisotropicFiltering); + } + + ADLX_RESULT GetTessellation(IADLXGPU* pGPU, IADLX3DTessellation** pp3DTessellation) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DSettingsServices1, GetTessellation); + } + + ADLX_RESULT GetRadeonSuperResolution(IADLX3DRadeonSuperResolution** pp3DRadeonSuperResolution) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DSettingsServices1, GetRadeonSuperResolution); + } + + ADLX_RESULT GetResetShaderCache(IADLXGPU* pGPU, IADLX3DResetShaderCache** pp3DResetShaderCache) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DSettingsServices1, GetResetShaderCache); + } + + ADLX_RESULT Get3DSettingsChangedHandling(IADLX3DSettingsChangedHandling** pp3DSettingsChangedHandling) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DSettingsServices1, Get3DSettingsChangedHandling); + } + + ADLX_RESULT GetAMDFluidMotionFrames(IADLX3DAMDFluidMotionFrames** pp3DAMDFluidMotionFrames) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DSettingsServices1, GetAMDFluidMotionFrames); + } +}; + class PyDisplay : public IADLXDisplay { public: @@ -280,6 +640,168 @@ class PyDisplay : public IADLXDisplay } }; +class PyDisplayGPUScaling : public IADLXDisplayGPUScaling +{ +public: + using IADLXDisplayGPUScaling::IADLXDisplayGPUScaling; + + adlx_long Acquire() override { + PYBIND11_OVERRIDE_PURE(adlx_long, IADLXInterface, Acquire); + } + + adlx_long Release() override { + PYBIND11_OVERRIDE_PURE(adlx_long, IADLXInterface, Release); + } + + ADLX_RESULT QueryInterface(const wchar_t* interfaceId, void** ppInterface) { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLXInterface, QueryInterface); + } + + ADLX_RESULT IsSupported(adlx_bool* supported) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLXDisplayGPUScaling, IsSupported); + } + + ADLX_RESULT IsEnabled(adlx_bool* enabled) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLXDisplayGPUScaling, IsEnabled); + } + + ADLX_RESULT SetEnabled(adlx_bool enabled) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLXDisplayGPUScaling, SetEnabled); + } +}; + +class PyDisplayScalingMode : public IADLXDisplayScalingMode +{ +public: + using IADLXDisplayScalingMode::IADLXDisplayScalingMode; + + adlx_long Acquire() override { + PYBIND11_OVERRIDE_PURE(adlx_long, IADLXInterface, Acquire); + } + + adlx_long Release() override { + PYBIND11_OVERRIDE_PURE(adlx_long, IADLXInterface, Release); + } + + ADLX_RESULT QueryInterface(const wchar_t* interfaceId, void** ppInterface) { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLXInterface, QueryInterface); + } + + ADLX_RESULT IsSupported(adlx_bool* supported) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLXDisplayScalingMode, IsSupported); + } + + ADLX_RESULT GetMode(ADLX_SCALE_MODE* currentMode) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLXDisplayScalingMode, GetMode); + } + + ADLX_RESULT SetMode(ADLX_SCALE_MODE mode) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLXDisplayScalingMode, SetMode); + } +}; + +class Py3DRadeonSuperResolution : public IADLX3DRadeonSuperResolution +{ +public: + using IADLX3DRadeonSuperResolution::IADLX3DRadeonSuperResolution; + + adlx_long Acquire() override { + PYBIND11_OVERRIDE_PURE(adlx_long, IADLXInterface, Acquire); + } + + adlx_long Release() override { + PYBIND11_OVERRIDE_PURE(adlx_long, IADLXInterface, Release); + } + + ADLX_RESULT QueryInterface(const wchar_t* interfaceId, void** ppInterface) { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLXInterface, QueryInterface); + } + + ADLX_RESULT IsSupported(adlx_bool* supported) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DRadeonSuperResolution, IsSupported); + } + + ADLX_RESULT IsEnabled(adlx_bool* enabled) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DRadeonSuperResolution, IsEnabled); + } + + ADLX_RESULT SetEnabled(adlx_bool enabled) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DRadeonSuperResolution, SetEnabled); + } + + ADLX_RESULT GetSharpnessRange(ADLX_IntRange* range) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DRadeonSuperResolution, GetSharpnessRange); + } + + ADLX_RESULT GetSharpness(adlx_int* currentSharpness) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DRadeonSuperResolution, GetSharpness); + } + + ADLX_RESULT SetSharpness(adlx_int sharpness) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DRadeonSuperResolution, SetSharpness); + } +}; + +class Py3DAMDFluidMotionFrames : public IADLX3DAMDFluidMotionFrames +{ +public: + using IADLX3DAMDFluidMotionFrames::IADLX3DAMDFluidMotionFrames; + + adlx_long Acquire() override { + PYBIND11_OVERRIDE_PURE(adlx_long, IADLXInterface, Acquire); + } + + adlx_long Release() override { + PYBIND11_OVERRIDE_PURE(adlx_long, IADLXInterface, Release); + } + + ADLX_RESULT QueryInterface(const wchar_t* interfaceId, void** ppInterface) { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLXInterface, QueryInterface); + } + + ADLX_RESULT IsSupported(adlx_bool* supported) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DAMDFluidMotionFrames, IsSupported); + } + + ADLX_RESULT IsEnabled(adlx_bool* enabled) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DAMDFluidMotionFrames, IsEnabled); + } + + ADLX_RESULT SetEnabled(adlx_bool enabled) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLX3DAMDFluidMotionFrames, SetEnabled); + } +}; + +class PyDisplayIntegerScaling : public IADLXDisplayIntegerScaling +{ +public: + using IADLXDisplayIntegerScaling::IADLXDisplayIntegerScaling; + + adlx_long Acquire() override { + PYBIND11_OVERRIDE_PURE(adlx_long, IADLXInterface, Acquire); + } + + adlx_long Release() override { + PYBIND11_OVERRIDE_PURE(adlx_long, IADLXInterface, Release); + } + + ADLX_RESULT QueryInterface(const wchar_t* interfaceId, void** ppInterface) { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLXInterface, QueryInterface); + } + + ADLX_RESULT IsSupported(adlx_bool* supported) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLXDisplayIntegerScaling, IsSupported); + } + + ADLX_RESULT IsEnabled(adlx_bool* enabled) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLXDisplayIntegerScaling, IsEnabled); + } + + ADLX_RESULT SetEnabled(adlx_bool enabled) override { + PYBIND11_OVERRIDE_PURE(ADLX_RESULT, IADLXDisplayIntegerScaling, SetEnabled); + } +}; + class PyDisplayChangeHandler : public IADLXDisplayChangedHandling { public: @@ -419,6 +941,12 @@ PYBIND11_MODULE(ADLXPybind, m) { .value("INTERLACED", ADLX_DISPLAY_SCAN_TYPE::INTERLACED) .export_values(); + py::enum_(m, "ADLX_SCALE_MODE") + .value("PRESERVE_ASPECT_RATIO", ADLX_SCALE_MODE::PRESERVE_ASPECT_RATIO) + .value("FULL_PANEL", ADLX_SCALE_MODE::FULL_PANEL) + .value("CENTERED", ADLX_SCALE_MODE::CENTERED) + .export_values(); + // ADLX_helper py::class_(m, "ADLXHelper") .def(py::init<>()) @@ -431,8 +959,8 @@ PYBIND11_MODULE(ADLXPybind, m) { .def("GetAdlMapping", &ADLXHelper::GetAdlMapping); // System - py::class_(m, "IADLXSystem") - .def(py::init<>()) + auto pyIADLXSystem = py::class_(m, "IADLXSystem"); + pyIADLXSystem.def(py::init<>()) .def("GetDisplaysServices", [](py::object self) { IADLXSystem *sys = self.cast(); IADLXDisplayServicesPtr displayService = nullptr; @@ -440,6 +968,79 @@ PYBIND11_MODULE(ADLXPybind, m) { return displayService; }, py::return_value_policy::move); + pyIADLXSystem.def(py::init<>()) + .def("Get3DSettingsServices", [](py::object self) { + IADLXSystem* sys = self.cast(); + IADLX3DSettingsServicesPtr settingsServices = nullptr; + sys->Get3DSettingsServices(&settingsServices); + return settingsServices; + }, py::return_value_policy::move); + + pyIADLXSystem.def(py::init<>()) + .def("Get3DSettingsServices1", [](py::object self) { + IADLXSystem* sys = self.cast(); + IADLX3DSettingsServicesPtr settingsServices = nullptr; + sys->Get3DSettingsServices(&settingsServices); + return (IADLX3DSettingsServices1Ptr) settingsServices; + }, py::return_value_policy::move); + + py::class_>(m, "IADLXDisplayGPUScaling") + .def(py::init<>()) + .def("IsSupported", [](py::object self) { + IADLXDisplayGPUScaling* displayGPUScaling = self.cast(); + adlx_bool isSupported = false; + displayGPUScaling->IsSupported(&isSupported); + return isSupported; + }) + .def("IsEnabled", [](py::object self) { + IADLXDisplayGPUScaling* displayGPUScaling = self.cast(); + adlx_bool isEnabled = false; + displayGPUScaling->IsEnabled(&isEnabled); + return isEnabled; + }) + .def("SetEnabled", [](py::object self, bool enable) { + IADLXDisplayGPUScaling* displayGPUScaling = self.cast(); + displayGPUScaling->SetEnabled(enable); + }); + + py::class_>(m, "IADLXDisplayScalingMode") + .def(py::init<>()) + .def("IsSupported", [](py::object self) { + IADLXDisplayScalingMode* displayScalingMode = self.cast(); + adlx_bool isSupported = false; + displayScalingMode->IsSupported(&isSupported); + return isSupported; + }) + .def("GetMode", [](py::object self) { + IADLXDisplayScalingMode* displayScalingMode = self.cast(); + ADLX_SCALE_MODE scaleMode; + displayScalingMode->GetMode(&scaleMode); + return scaleMode; + }) + .def("SetMode", [](py::object self, ADLX_SCALE_MODE mode) { + IADLXDisplayScalingMode* displayScalingMode = self.cast(); + displayScalingMode->SetMode(mode); + }); + + py::class_>(m, "IADLXDisplayIntegerScaling") + .def(py::init<>()) + .def("IsSupported", [](py::object self) { + IADLXDisplayIntegerScaling* displayIntegerScaling = self.cast(); + adlx_bool isSupported = false; + displayIntegerScaling->IsSupported(&isSupported); + return isSupported; + }) + .def("IsEnabled", [](py::object self) { + IADLXDisplayIntegerScaling* displayIntegerScaling = self.cast(); + adlx_bool isEnabled = false; + displayIntegerScaling->IsEnabled(&isEnabled); + return isEnabled; + }) + .def("SetEnabled", [](py::object self, bool enable) { + IADLXDisplayIntegerScaling* displayIntegerScaling = self.cast(); + displayIntegerScaling->SetEnabled(enable); + }); + // displayService py::class_>(m, "IADLXDisplayServices") .def(py::init<>()) @@ -466,7 +1067,40 @@ PYBIND11_MODULE(ADLXPybind, m) { IADLXDisplayChangedHandlingPtr handler = nullptr; disService->GetDisplayChangedHandling(&handler); return handler; - }, py::return_value_policy::move); + }, py::return_value_policy::move) + .def("GetGPUScaling", [](py::object self, IADLXDisplayPtr display) { + IADLXDisplayServices* disService = self.cast(); + IADLXDisplayGPUScalingPtr gpuScaling; + disService->GetGPUScaling(display, &gpuScaling); + return gpuScaling; + }) + .def("GetScalingMode", [](py::object self, IADLXDisplayPtr display) { + IADLXDisplayServices* disService = self.cast(); + IADLXDisplayScalingModePtr scalingMode; + disService->GetScalingMode(display, &scalingMode); + return scalingMode; + }) + .def("GetIntegerScaling", [](py::object self, IADLXDisplayPtr display) { + IADLXDisplayServices* disService = self.cast(); + IADLXDisplayIntegerScalingPtr integerScaling; + disService->GetIntegerScaling(display, &integerScaling); + return integerScaling; + }); + + py::class_>(m, "IADLXGPU") + .def(py::init<>()) + .def("vendorId", [](py::object self) { + IADLXGPU* gpu = self.cast(); + const char* vendorId = nullptr; + gpu->VendorId(&vendorId); + return py::str(vendorId); + }) + .def("name", [](py::object self) { + IADLXGPU* gpu = self.cast(); + const char* name = nullptr; + gpu->Name(&name); + return py::str(name); + }); // Display py::class_>(m, "IADLXDisplay") @@ -530,7 +1164,13 @@ PYBIND11_MODULE(ADLXPybind, m) { adlx_size id; display->UniqueId(&id); return id; - }); + }) + .def("GetGPU", [](py::object self) { + IADLXDisplay* display = self.cast(); + IADLXGPUPtr GPU; + display->GetGPU(&GPU); + return GPU; + }); // Display change handler py::class_>(m, "IADLXDisplayChangedHandling") @@ -548,4 +1188,188 @@ PYBIND11_MODULE(ADLXPybind, m) { py::class_(m, "DisplayListCallBack") .def(py::init<>()) .def_readwrite("call", &DisplayListCallBack::m_call); -} \ No newline at end of file + + // 3D + py::class_>(m, "IADLX3DAntiLag") + .def(py::init<>()) + .def("IsSupported", [](py::object self) { + IADLX3DAntiLag* antiLag = self.cast(); + adlx_bool isSupported = false; + antiLag->IsSupported(&isSupported); + return isSupported; + }) + .def("IsEnabled", [](py::object self) { + IADLX3DAntiLag* antiLag = self.cast(); + adlx_bool isEnabled = false; + antiLag->IsEnabled(&isEnabled); + return isEnabled; + }) + .def("SetEnabled", [](py::object self, bool enable) { + IADLX3DAntiLag* antiLag = self.cast(); + antiLag->SetEnabled(enable); + }); + + py::class_>(m, "IADLX3DChill") + .def(py::init<>()) + .def("IsSupported", [](py::object self) { + IADLX3DChill* chill = self.cast(); + adlx_bool isSupported = false; + chill->IsSupported(&isSupported); + return isSupported; + }) + .def("IsEnabled", [](py::object self) { + IADLX3DChill* chill = self.cast(); + adlx_bool isEnabled = false; + chill->IsEnabled(&isEnabled); + return isEnabled; + }) + .def("SetEnabled", [](py::object self, bool enable) { + IADLX3DChill* chill = self.cast(); + chill->SetEnabled(enable); + }) + .def("GetMinFPS", [](py::object self) { + IADLX3DChill* chill = self.cast(); + adlx_int minFPS; + chill->GetMinFPS(&minFPS); + return minFPS; + }) + .def("GetMaxFPS", [](py::object self) { + IADLX3DChill* chill = self.cast(); + adlx_int maxFPS; + chill->GetMaxFPS(&maxFPS); + return maxFPS; + }) + .def("SetMinFPS", [](py::object self, int minFPS) { + IADLX3DChill* chill = self.cast(); + chill->SetMinFPS(minFPS); + }) + .def("SetMaxFPS", [](py::object self, int maxFPS) { + IADLX3DChill* chill = self.cast(); + chill->SetMaxFPS(maxFPS); + }); + + py::class_>(m, "IADLX3DBoost") + .def(py::init<>()) + .def("IsSupported", [](py::object self) { + IADLX3DBoost* boost = self.cast(); + adlx_bool isSupported = false; + boost->IsSupported(&isSupported); + return isSupported; + }) + .def("IsEnabled", [](py::object self) { + IADLX3DBoost* boost = self.cast(); + adlx_bool isEnabled = false; + boost->IsEnabled(&isEnabled); + return isEnabled; + }) + .def("SetEnabled", [](py::object self, bool enable) { + IADLX3DBoost* boost = self.cast(); + boost->SetEnabled(enable); + }) + .def("GetResolutionRange", [](py::object self) { + IADLX3DBoost* boost = self.cast(); + ADLX_IntRange resolutionRange; + boost->GetResolutionRange(&resolutionRange); + return resolutionRange; + }) + .def("GetResolution", [](py::object self) { + IADLX3DBoost* boost = self.cast(); + adlx_int resolution; + boost->GetResolution(&resolution); + return resolution; + }) + .def("SetResolution", [](py::object self, int resolution) { + IADLX3DBoost* boost = self.cast(); + boost->SetResolution(resolution); + }); + + py::class_>(m, "IADLX3DRadeonSuperResolution") + .def(py::init<>()) + .def("IsSupported", [](py::object self) { + IADLX3DRadeonSuperResolution* radeonSuperResolution = self.cast(); + adlx_bool isSupported = false; + radeonSuperResolution->IsSupported(&isSupported); + return isSupported; + }) + .def("IsEnabled", [](py::object self) { + IADLX3DRadeonSuperResolution* radeonSuperResolution = self.cast(); + adlx_bool isEnabled = false; + radeonSuperResolution->IsEnabled(&isEnabled); + return isEnabled; + }) + .def("SetEnabled", [](py::object self, bool enable) { + IADLX3DRadeonSuperResolution* radeonSuperResolution = self.cast(); + radeonSuperResolution->SetEnabled(enable); + }) + .def("GetSharpnessRange", [](py::object self) { + IADLX3DRadeonSuperResolution* radeonSuperResolution = self.cast(); + ADLX_IntRange sharpnessRange; + radeonSuperResolution->GetSharpnessRange(&sharpnessRange); + return sharpnessRange; + }) + .def("GetSharpness", [](py::object self) { + IADLX3DRadeonSuperResolution* radeonSuperResolution = self.cast(); + adlx_int sharpness; + radeonSuperResolution->GetSharpness(&sharpness); + return sharpness; + }) + .def("SetSharpness", [](py::object self, int sharpness) { + IADLX3DRadeonSuperResolution* radeonSuperResolution = self.cast(); + radeonSuperResolution->SetSharpness(sharpness); + }); + + py::class_>(m, "IADLX3DAMDFluidMotionFrames") + .def(py::init<>()) + .def("IsSupported", [](py::object self) { + IADLX3DAMDFluidMotionFrames* amdFluidMotionFrame = self.cast(); + adlx_bool isSupported = false; + amdFluidMotionFrame->IsSupported(&isSupported); + return isSupported; + }) + .def("IsEnabled", [](py::object self) { + IADLX3DAMDFluidMotionFrames* amdFluidMotionFrame = self.cast(); + adlx_bool isEnabled = false; + amdFluidMotionFrame->IsEnabled(&isEnabled); + return isEnabled; + }) + .def("SetEnabled", [](py::object self, bool enable) { + IADLX3DAMDFluidMotionFrames* amdFluidMotionFrame = self.cast(); + amdFluidMotionFrame->SetEnabled(enable); + }); + + py::class_>(m, "IADLX3DSettingsServices") + .def(py::init<>()) + .def("GetAntiLag", [](py::object self, IADLXGPUPtr gpu) { + IADLX3DSettingsServices* settingsServices = self.cast(); + IADLX3DAntiLagPtr antiLag; + settingsServices->GetAntiLag(gpu, &antiLag); + return antiLag; + }) + .def("GetChill", [](py::object self, IADLXGPUPtr gpu) { + IADLX3DSettingsServices* settingsServices = self.cast(); + IADLX3DChillPtr chill; + settingsServices->GetChill(gpu, &chill); + return chill; + }) + .def("GetBoost", [](py::object self, IADLXGPUPtr gpu) { + IADLX3DSettingsServices* settingsServices = self.cast(); + IADLX3DBoostPtr boost; + settingsServices->GetBoost(gpu, &boost); + return boost; + }) + .def("GetRadeonSuperResolution", [](py::object self) { + IADLX3DSettingsServices* settingsServices = self.cast(); + IADLX3DRadeonSuperResolutionPtr radeonSuperResolution; + settingsServices->GetRadeonSuperResolution(&radeonSuperResolution); + return radeonSuperResolution; + }); + + py::class_>(m, "IADLX3DSettingsServices1") + .def(py::init<>()) + .def("GetAMDFluidMotionFrame", [](py::object self) { + IADLX3DSettingsServices1* settingsServices1 = self.cast(); + IADLX3DAMDFluidMotionFramesPtr amdFluidMotionFrame; + settingsServices1->GetAMDFluidMotionFrames(&amdFluidMotionFrame); + return amdFluidMotionFrame; + }); +}