Skip to content

Commit

Permalink
Cmake: "NRI_ENABLE_EXTERNAL_LIBRARIES" renamed to a clear "NRI_ENABLE…
Browse files Browse the repository at this point in the history
…_D3D_EXTENSIONS" (this settings has always been about NVAPI and AMD AGS)
  • Loading branch information
dzhdanNV committed Jan 22, 2025
1 parent 8b7835d commit a4e2831
Show file tree
Hide file tree
Showing 14 changed files with 80 additions and 70 deletions.
60 changes: 35 additions & 25 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
cmake_minimum_required(VERSION 3.15)

# Options
if(WIN32)
set(IS_WIN ON)
else()
set(IS_WIN OFF)
endif()

option(NRI_STATIC_LIBRARY "Build static library" OFF)
option(NRI_ENABLE_NVTX_SUPPORT "Annotations for NVIDIA Nsight Systems" OFF)
option(NRI_ENABLE_DEBUG_NAMES_AND_ANNOTATIONS "Enable debug names, host and device annotations" ON)

# Options: backends
option(NRI_ENABLE_NONE_SUPPORT "Enable NONE backend" ON)
option(NRI_ENABLE_D3D11_SUPPORT "Enable D3D11 backend" ON)
option(NRI_ENABLE_D3D12_SUPPORT "Enable D3D12 backend" ON)
option(NRI_ENABLE_D3D11_SUPPORT "Enable D3D11 backend" ${IS_WIN})
option(NRI_ENABLE_D3D12_SUPPORT "Enable D3D12 backend" ${IS_WIN})
option(NRI_ENABLE_VK_SUPPORT "Enable VULKAN backend" ON)

# Options: VK specific
Expand All @@ -22,7 +28,13 @@ set(NRI_AGILITY_SDK_VERSION "614" CACHE STRING "Agility SDK version")
set(NRI_AGILITY_SDK_DIR "AgilitySDK" CACHE STRING "Directory where Agility SDK binaries will be copied to relative to 'CMAKE_RUNTIME_OUTPUT_DIRECTORY'")

# Options: D3D11/D3D12 specific (PIX events are always enabled if "WinPixEventRuntime.dll" is nearby)
option(NRI_ENABLE_EXTERNAL_LIBRARIES "Enable vendor specific extension libraries (NVAPI and AMD AGS)" ON)
if(NRI_ENABLE_D3D11_SUPPORT OR NRI_ENABLE_D3D12_SUPPORT)
set(HAS_D3D ON)
else()
set(HAS_D3D OFF)
endif()

option(NRI_ENABLE_D3D_EXTENSIONS "Enable vendor specific extension libraries for D3D (NVAPI and AMD AGS)" ${HAS_D3D})

# Is submodule?
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
Expand Down Expand Up @@ -140,16 +152,16 @@ if(NRI_ENABLE_DEBUG_NAMES_AND_ANNOTATIONS)
set(COMPILE_DEFINITIONS ${COMPILE_DEFINITIONS} NRI_ENABLE_DEBUG_NAMES_AND_ANNOTATIONS=1)
endif()

if(NRI_ENABLE_EXTERNAL_LIBRARIES)
set(COMPILE_DEFINITIONS ${COMPILE_DEFINITIONS} NRI_ENABLE_EXTERNAL_LIBRARIES=1)
if(NRI_ENABLE_D3D_EXTENSIONS)
set(COMPILE_DEFINITIONS ${COMPILE_DEFINITIONS} NRI_ENABLE_D3D_EXTENSIONS=1)
endif()

if(NRI_ENABLE_NVTX_SUPPORT)
set(COMPILE_DEFINITIONS ${COMPILE_DEFINITIONS} NRI_ENABLE_NVTX_SUPPORT=1)
endif()

# External libs
if(WIN32 AND NRI_ENABLE_EXTERNAL_LIBRARIES AND(NRI_ENABLE_D3D11_SUPPORT OR NRI_ENABLE_D3D12_SUPPORT))
if(NRI_ENABLE_D3D_EXTENSIONS)
find_library(NVAPI_LIB NAMES nvapi64 nvapi PATHS "External/nvapi/${NVAPI_BIN_ARCHITECTURE}" REQUIRED) # statically linked
find_library(AGS_LIB NAMES amd_ags_${BIN_ARCHITECTURE} PATHS "External/amdags/ags_lib/lib" REQUIRED) # dynamically loaded

Expand All @@ -174,7 +186,7 @@ if(NRI_ENABLE_NONE_SUPPORT)
endif()

# D3D11
if(WIN32 AND NRI_ENABLE_D3D11_SUPPORT)
if(NRI_ENABLE_D3D11_SUPPORT)
message("NRI adding backend: D3D11")

set(COMPILE_DEFINITIONS ${COMPILE_DEFINITIONS} NRI_ENABLE_D3D11_SUPPORT=1)
Expand All @@ -183,7 +195,7 @@ if(WIN32 AND NRI_ENABLE_D3D11_SUPPORT)
file(GLOB D3D11_SOURCE "Source/D3D11/*")
source_group("" FILES ${D3D11_SOURCE})

if(NRI_ENABLE_EXTERNAL_LIBRARIES)
if(NRI_ENABLE_D3D_EXTENSIONS)
add_library(NRI_D3D11 STATIC ${D3D11_SOURCE} ${NVAPI_HEADERS} ${AMDAGS_HEADERS})
target_link_libraries(NRI_D3D11 PRIVATE ${NVAPI_LIB})
else()
Expand All @@ -198,7 +210,7 @@ if(WIN32 AND NRI_ENABLE_D3D11_SUPPORT)
endif()

# D3D12
if(WIN32 AND NRI_ENABLE_D3D12_SUPPORT)
if(NRI_ENABLE_D3D12_SUPPORT)
message("NRI adding backend: D3D12")

set(COMPILE_DEFINITIONS ${COMPILE_DEFINITIONS} NRI_ENABLE_D3D12_SUPPORT=1)
Expand All @@ -207,7 +219,7 @@ if(WIN32 AND NRI_ENABLE_D3D12_SUPPORT)
file(GLOB D3D12_SOURCE "Source/D3D12/*" "External/memalloc/D3D12*.*")
source_group("" FILES ${D3D12_SOURCE})

if(NRI_ENABLE_EXTERNAL_LIBRARIES)
if(NRI_ENABLE_D3D_EXTENSIONS)
add_library(NRI_D3D12 STATIC ${D3D12_SOURCE} ${NVAPI_HEADERS} ${AMDAGS_HEADERS})
target_link_libraries(NRI_D3D12 PRIVATE ${NVAPI_LIB})
else()
Expand Down Expand Up @@ -345,11 +357,11 @@ if(NRI_ENABLE_NONE_SUPPORT)
target_link_libraries(${PROJECT_NAME} PRIVATE NRI_NONE)
endif()

if(WIN32 AND NRI_ENABLE_D3D11_SUPPORT)
if(NRI_ENABLE_D3D11_SUPPORT)
target_link_libraries(${PROJECT_NAME} PRIVATE NRI_D3D11)
endif()

if(WIN32 AND NRI_ENABLE_D3D12_SUPPORT)
if(NRI_ENABLE_D3D12_SUPPORT)
target_link_libraries(${PROJECT_NAME} PRIVATE NRI_D3D12)
endif()

Expand All @@ -362,17 +374,15 @@ set_property(TARGET ${PROJECT_NAME} PROPERTY FOLDER ${PROJECT_FOLDER})
set_target_properties(${PROJECT_NAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
message("NRI output path: '${CMAKE_RUNTIME_OUTPUT_DIRECTORY}'")

if(WIN32 AND NRI_ENABLE_EXTERNAL_LIBRARIES)
if(NRI_ENABLE_D3D11_SUPPORT OR NRI_ENABLE_D3D12_SUPPORT)
# Function - copy a library to the output folder of a project
function(copy_library PROJECT LIBRARY_NAME)
add_custom_command(TARGET ${PROJECT} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${LIBRARY_NAME} $<TARGET_FILE_DIR:${PROJECT}>
COMMAND_EXPAND_LISTS)
endfunction()

# Copy AMD AGS into the output folder
find_file(AMD_AGS_DLL NAMES amd_ags_x64.dll PATHS "External/amdags/ags_lib/lib")
copy_library(${PROJECT_NAME} ${AMD_AGS_DLL})
endif()
if(NRI_ENABLE_D3D_EXTENSIONS)
# Function - copy a library to the output folder of a project
function(copy_library PROJECT LIBRARY_NAME)
add_custom_command(TARGET ${PROJECT} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${LIBRARY_NAME} $<TARGET_FILE_DIR:${PROJECT}>
COMMAND_EXPAND_LISTS)
endfunction()

# Copy AMD AGS into the output folder
find_file(AMD_AGS_DLL NAMES amd_ags_x64.dll PATHS "External/amdags/ags_lib/lib")
copy_library(${PROJECT_NAME} ${AMD_AGS_DLL})
endif()
14 changes: 7 additions & 7 deletions Source/D3D11/CommandBufferD3D11.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ CommandBufferD3D11::CommandBufferD3D11(DeviceD3D11& device)
}

CommandBufferD3D11::~CommandBufferD3D11() {
#if NRI_ENABLE_EXTERNAL_LIBRARIES
#if NRI_ENABLE_D3D_EXTENSIONS
if (m_DeferredContext && m_DeferredContext->GetType() == D3D11_DEVICE_CONTEXT_DEFERRED) {
if (m_Device.HasNvExt()) {
NvAPI_Status status = NvAPI_D3D11_EndUAVOverlap(m_DeferredContext);
Expand Down Expand Up @@ -65,7 +65,7 @@ Result CommandBufferD3D11::Create(ID3D11DeviceContext* precreatedContext) {
RETURN_ON_BAD_HRESULT(&m_Device, hr, "QueryInterface(ID3DUserDefinedAnnotation)");

// Skip UAV barriers by default on the deferred context
#if NRI_ENABLE_EXTERNAL_LIBRARIES
#if NRI_ENABLE_D3D_EXTENSIONS
if (m_DeferredContext && m_DeferredContext->GetType() == D3D11_DEVICE_CONTEXT_DEFERRED) {
if (m_Device.HasNvExt()) {
NvAPI_Status res = NvAPI_D3D11_BeginUAVOverlap(m_DeferredContext);
Expand Down Expand Up @@ -143,7 +143,7 @@ NRI_INLINE void CommandBufferD3D11::SetScissors(const Rect* rects, uint32_t rect

NRI_INLINE void CommandBufferD3D11::SetDepthBounds(float boundsMin, float boundsMax) {
if (m_DepthBounds[0] != boundsMin || m_DepthBounds[1] != boundsMax) {
#if NRI_ENABLE_EXTERNAL_LIBRARIES
#if NRI_ENABLE_D3D_EXTENSIONS
bool isEnabled = boundsMin != 0.0f || boundsMax != 1.0f;
if (m_Device.HasNvExt()) {
NvAPI_Status status = NvAPI_D3D11_SetDepthBoundsTest(m_DeferredContext, isEnabled, boundsMin, boundsMax);
Expand Down Expand Up @@ -267,7 +267,7 @@ NRI_INLINE void CommandBufferD3D11::BeginRendering(const AttachmentsDesc& attach

m_DeferredContext->OMSetRenderTargets(m_RenderTargetNum, m_RenderTargets.data(), m_DepthStencil);

#if NRI_ENABLE_EXTERNAL_LIBRARIES
#if NRI_ENABLE_D3D_EXTENSIONS
// Shading rate
if (m_Device.HasNvExt() && m_Device.GetDesc().shadingRateTier >= 2) {
ID3D11NvShadingRateResourceView* shadingRateImage = nullptr;
Expand Down Expand Up @@ -399,7 +399,7 @@ NRI_INLINE void CommandBufferD3D11::DrawIndirect(const Buffer& buffer, uint64_t
MaybeUnused(countBuffer, countBufferOffset);

const BufferD3D11& bufferD3D11 = (BufferD3D11&)buffer;
#if NRI_ENABLE_EXTERNAL_LIBRARIES
#if NRI_ENABLE_D3D_EXTENSIONS
if (countBuffer && m_Device.HasAmdExt()) {
const BufferD3D11* countBufferD3D11 = (BufferD3D11*)countBuffer;
const AmdExt& amdExt = m_Device.GetAmdExt();
Expand Down Expand Up @@ -428,7 +428,7 @@ NRI_INLINE void CommandBufferD3D11::DrawIndexedIndirect(const Buffer& buffer, ui
MaybeUnused(countBuffer, countBufferOffset);

const BufferD3D11& bufferD3D11 = (BufferD3D11&)buffer;
#if NRI_ENABLE_EXTERNAL_LIBRARIES
#if NRI_ENABLE_D3D_EXTENSIONS
if (countBuffer && m_Device.HasAmdExt()) {
const BufferD3D11* countBufferD3D11 = (BufferD3D11*)countBuffer;
const AmdExt& amdExt = m_Device.GetAmdExt();
Expand Down Expand Up @@ -587,7 +587,7 @@ NRI_INLINE void CommandBufferD3D11::DispatchIndirect(const Buffer& buffer, uint6

NRI_INLINE void CommandBufferD3D11::Barrier(const BarrierGroupDesc& barrierGroupDesc) {
MaybeUnused(barrierGroupDesc);
#if NRI_ENABLE_EXTERNAL_LIBRARIES
#if NRI_ENABLE_D3D_EXTENSIONS
if (barrierGroupDesc.textureNum == 0 && barrierGroupDesc.bufferNum == 0)
return;

Expand Down
2 changes: 1 addition & 1 deletion Source/D3D11/DescriptorD3D11.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ struct DescriptorD3D11 final : public DebugNameBase {
return (ID3D11UnorderedAccessView*)m_Descriptor.GetInterface();
}

#if NRI_ENABLE_EXTERNAL_LIBRARIES
#if NRI_ENABLE_D3D_EXTENSIONS
inline operator ID3D11NvShadingRateResourceView*() const {
return (ID3D11NvShadingRateResourceView*)m_Descriptor.GetInterface();
}
Expand Down
2 changes: 1 addition & 1 deletion Source/D3D11/DescriptorD3D11.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ Result DescriptorD3D11::Create(const Texture2DViewDesc& textureViewDesc) {
break;
}
case Texture2DViewType::SHADING_RATE_ATTACHMENT: {
#if NRI_ENABLE_EXTERNAL_LIBRARIES
#if NRI_ENABLE_D3D_EXTENSIONS
if (m_Device.HasNvExt()) {
NV_D3D11_SHADING_RATE_RESOURCE_VIEW_DESC desc = {NV_D3D11_SHADING_RATE_RESOURCE_VIEW_DESC_VER};
desc.Format = format;
Expand Down
4 changes: 2 additions & 2 deletions Source/D3D11/DeviceD3D11.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct DeviceD3D11 final : public DeviceBase {
::LeaveCriticalSection(&m_CriticalSection);
}

#if NRI_ENABLE_EXTERNAL_LIBRARIES
#if NRI_ENABLE_D3D_EXTENSIONS
inline bool HasNvExt() const {
return m_NvExt.available;
}
Expand Down Expand Up @@ -142,7 +142,7 @@ struct DeviceD3D11 final : public DeviceBase {

private:
// Order of destructors is important
#if NRI_ENABLE_EXTERNAL_LIBRARIES
#if NRI_ENABLE_D3D_EXTENSIONS
NvExt m_NvExt = {};
AmdExt m_AmdExt = {};
#endif
Expand Down
16 changes: 8 additions & 8 deletions Source/D3D11/DeviceD3D11.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ DeviceD3D11::DeviceD3D11(const CallbackInterface& callbacks, const AllocationCal
}

DeviceD3D11::~DeviceD3D11() {
#if NRI_ENABLE_EXTERNAL_LIBRARIES
#if NRI_ENABLE_D3D_EXTENSIONS
if (m_ImmediateContext) {
if (HasNvExt()) {
NvAPI_Status status = NvAPI_D3D11_EndUAVOverlap(m_ImmediateContext);
Expand All @@ -52,7 +52,7 @@ DeviceD3D11::~DeviceD3D11() {

DeleteCriticalSection(&m_CriticalSection);

#if NRI_ENABLE_EXTERNAL_LIBRARIES
#if NRI_ENABLE_D3D_EXTENSIONS
if (HasAmdExt() && !m_IsWrapped)
m_AmdExt.DestroyDeviceD3D11(m_AmdExt.context, m_Device, nullptr, m_ImmediateContext, nullptr);
#endif
Expand Down Expand Up @@ -98,7 +98,7 @@ Result DeviceD3D11::Create(const DeviceCreationDesc& desc, const DeviceCreationD
bool isDrawIndirectCountSupported = false;
bool isShaderAtomicsI64Supported = false;

#if NRI_ENABLE_EXTERNAL_LIBRARIES
#if NRI_ENABLE_D3D_EXTENSIONS
uint32_t shaderExtRegister = desc.shaderExtRegister ? desc.shaderExtRegister : NRI_SHADER_EXT_REGISTER;
if (HasAmdExt()) {
AGSDX11DeviceCreationParams deviceCreationParams = {};
Expand Down Expand Up @@ -140,7 +140,7 @@ Result DeviceD3D11::Create(const DeviceCreationDesc& desc, const DeviceCreationD

RETURN_ON_BAD_HRESULT(this, hr, "D3D11CreateDevice()");

#if NRI_ENABLE_EXTERNAL_LIBRARIES
#if NRI_ENABLE_D3D_EXTENSIONS
if (HasNvExt()) {
REPORT_ERROR_ON_BAD_STATUS(this, NvAPI_D3D_RegisterDevice(deviceTemp));
REPORT_ERROR_ON_BAD_STATUS(this, NvAPI_D3D11_SetNvShaderExtnSlot(deviceTemp, shaderExtRegister));
Expand All @@ -167,7 +167,7 @@ Result DeviceD3D11::Create(const DeviceCreationDesc& desc, const DeviceCreationD
REPORT_INFO(this, "Using ID3D11DeviceContext%u", m_ImmediateContextVersion);

// Skip UAV barriers by default on the immediate context
#if NRI_ENABLE_EXTERNAL_LIBRARIES
#if NRI_ENABLE_D3D_EXTENSIONS
if (HasNvExt()) {
NvAPI_Status status = NvAPI_D3D11_BeginUAVOverlap(m_ImmediateContext);
if (status != NVAPI_OK)
Expand Down Expand Up @@ -377,7 +377,7 @@ void DeviceD3D11::FillDesc() {
bool isShaderAtomicsF16Supported = false;
bool isShaderAtomicsF32Supported = false;
bool isGetSpecialSupported = false;
#if NRI_ENABLE_EXTERNAL_LIBRARIES
#if NRI_ENABLE_D3D_EXTENSIONS
NV_D3D11_FEATURE_DATA_RASTERIZER_SUPPORT rasterizerFeatures = {};
NV_D3D1x_GRAPHICS_CAPS caps = {};

Expand Down Expand Up @@ -416,7 +416,7 @@ void DeviceD3D11::FillDesc() {

void DeviceD3D11::InitializeNvExt(bool isNVAPILoadedInApp, bool isImported) {
MaybeUnused(isNVAPILoadedInApp, isImported);
#if NRI_ENABLE_EXTERNAL_LIBRARIES
#if NRI_ENABLE_D3D_EXTENSIONS
if (GetModuleHandleA("renderdoc.dll") != nullptr) {
REPORT_WARNING(this, "NVAPI is disabled, because RenderDoc library has been loaded");
return;
Expand All @@ -435,7 +435,7 @@ void DeviceD3D11::InitializeNvExt(bool isNVAPILoadedInApp, bool isImported) {

void DeviceD3D11::InitializeAmdExt(AGSContext* agsContext, bool isImported) {
MaybeUnused(agsContext, isImported);
#if NRI_ENABLE_EXTERNAL_LIBRARIES
#if NRI_ENABLE_D3D_EXTENSIONS
if (isImported && !agsContext) {
REPORT_WARNING(this, "AMDAGS is disabled, because 'agsContext' is not provided");
return;
Expand Down
2 changes: 1 addition & 1 deletion Source/D3D11/PipelineD3D11.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ struct PipelineD3D11 final : public DebugNameBase {
ComPtr<ID3D11InputLayout> m_InputLayout;
ComPtr<ID3D11DepthStencilState> m_DepthStencilState;
ComPtr<ID3D11BlendState1> m_BlendState;
#if NRI_ENABLE_EXTERNAL_LIBRARIES
#if NRI_ENABLE_D3D_EXTENSIONS
NvAPI_D3D11_RASTERIZER_DESC_EX m_RasterizerDesc = {};
#else
D3D11_RASTERIZER_DESC m_RasterizerDesc = {};
Expand Down
4 changes: 2 additions & 2 deletions Source/D3D11/PipelineD3D11.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ Result PipelineD3D11::Create(const GraphicsPipelineDesc& pipelineDesc) {

// Ex
memcpy(&m_RasterizerDesc, &rasterizerDesc, sizeof(D3D11_RASTERIZER_DESC));
#if NRI_ENABLE_EXTERNAL_LIBRARIES
#if NRI_ENABLE_D3D_EXTENSIONS
m_RasterizerDesc.ForcedSampleCount = sampleNum > 1 ? sampleNum : 0;
m_RasterizerDesc.ProgrammableSamplePositionsEnable = true;
m_RasterizerDesc.SampleCount = sampleNum;
Expand Down Expand Up @@ -215,7 +215,7 @@ Result PipelineD3D11::Create(const ComputePipelineDesc& pipelineDesc) {

void PipelineD3D11::ChangeSamplePositions(ID3D11DeviceContextBest* deferredContext, const SamplePositionsState& samplePositionState) {
MaybeUnused(deferredContext, samplePositionState);
#if NRI_ENABLE_EXTERNAL_LIBRARIES
#if NRI_ENABLE_D3D_EXTENSIONS
if (IsCompute())
return;

Expand Down
2 changes: 1 addition & 1 deletion Source/D3D11/SharedD3D11.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ struct SamplePositionsState {

} // namespace nri

#if NRI_ENABLE_EXTERNAL_LIBRARIES
#if NRI_ENABLE_D3D_EXTENSIONS
# include "amdags/ags_lib/inc/amd_ags.h"
# include "nvapi/nvShaderExtnEnums.h"
# include "nvapi/nvapi.h"
Expand Down
12 changes: 6 additions & 6 deletions Source/D3D11/SwapChainD3D11.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ NRI_INLINE Result SwapChainD3D11::WaitForPresent() {
}

NRI_INLINE Result SwapChainD3D11::Present() {
#if NRI_ENABLE_EXTERNAL_LIBRARIES
#if NRI_ENABLE_D3D_EXTENSIONS
if (m_Desc.allowLowLatency)
SetLatencyMarker((LatencyMarker)PRESENT_START);
#endif
Expand All @@ -189,7 +189,7 @@ NRI_INLINE Result SwapChainD3D11::Present() {
HRESULT hr = m_SwapChain->Present(m_Desc.verticalSyncInterval, flags);
RETURN_ON_BAD_HRESULT(&m_Device, hr, "IDXGISwapChain::Present()");

#if NRI_ENABLE_EXTERNAL_LIBRARIES
#if NRI_ENABLE_D3D_EXTENSIONS
if (m_Desc.allowLowLatency)
SetLatencyMarker((LatencyMarker)PRESENT_END);
#endif
Expand All @@ -200,7 +200,7 @@ NRI_INLINE Result SwapChainD3D11::Present() {
}

NRI_INLINE Result SwapChainD3D11::SetLatencySleepMode(const LatencySleepMode& latencySleepMode) {
#if NRI_ENABLE_EXTERNAL_LIBRARIES
#if NRI_ENABLE_D3D_EXTENSIONS
NV_SET_SLEEP_MODE_PARAMS params = {NV_SET_SLEEP_MODE_PARAMS_VER};
params.bLowLatencyMode = latencySleepMode.lowLatencyMode;
params.bLowLatencyBoost = latencySleepMode.lowLatencyBoost;
Expand All @@ -218,7 +218,7 @@ NRI_INLINE Result SwapChainD3D11::SetLatencySleepMode(const LatencySleepMode& la
}

NRI_INLINE Result SwapChainD3D11::SetLatencyMarker(LatencyMarker latencyMarker) {
#if NRI_ENABLE_EXTERNAL_LIBRARIES
#if NRI_ENABLE_D3D_EXTENSIONS
NV_LATENCY_MARKER_PARAMS params = {NV_LATENCY_MARKER_PARAMS_VER};
params.frameID = m_PresentId;
params.markerType = (NV_LATENCY_MARKER_TYPE)latencyMarker;
Expand All @@ -234,7 +234,7 @@ NRI_INLINE Result SwapChainD3D11::SetLatencyMarker(LatencyMarker latencyMarker)
}

NRI_INLINE Result SwapChainD3D11::LatencySleep() {
#if NRI_ENABLE_EXTERNAL_LIBRARIES
#if NRI_ENABLE_D3D_EXTENSIONS
NvAPI_Status status = NvAPI_D3D_Sleep(m_Device.GetNativeObject());

return status == NVAPI_OK ? Result::SUCCESS : Result::FAILURE;
Expand All @@ -245,7 +245,7 @@ NRI_INLINE Result SwapChainD3D11::LatencySleep() {

NRI_INLINE Result SwapChainD3D11::GetLatencyReport(LatencyReport& latencyReport) {
latencyReport = {};
#if NRI_ENABLE_EXTERNAL_LIBRARIES
#if NRI_ENABLE_D3D_EXTENSIONS
NV_LATENCY_RESULT_PARAMS params = {NV_LATENCY_RESULT_PARAMS_VER};
NvAPI_Status status = NvAPI_D3D_GetLatency(m_Device.GetNativeObject(), &params);

Expand Down
Loading

0 comments on commit a4e2831

Please sign in to comment.