Skip to content

Commit 192ad3e

Browse files
RenderDeviceBase, DeviceContextBase: fixed compile issues with std::min/std::max on Windows
1 parent 5a6dddd commit 192ad3e

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

Graphics/GraphicsEngine/include/DeviceContextBase.hpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ inline void DeviceContextBase<ImplementationTraits>::SetVertexBuffers(
741741
m_VertexStreams[s] = VertexStreamInfo<BufferImplType>{};
742742
m_NumVertexStreams = 0;
743743
}
744-
m_NumVertexStreams = std::max(m_NumVertexStreams, StartSlot + NumBuffersSet);
744+
m_NumVertexStreams = (std::max)(m_NumVertexStreams, StartSlot + NumBuffersSet);
745745

746746
for (Uint32 Buff = 0; Buff < NumBuffersSet; ++Buff)
747747
{
@@ -903,7 +903,7 @@ inline void DeviceContextBase<ImplementationTraits>::SetViewports(
903903
}
904904

905905
DEV_CHECK_ERR(NumViewports < MAX_VIEWPORTS, "Number of viewports (", NumViewports, ") exceeds the limit (", MAX_VIEWPORTS, ")");
906-
m_NumViewports = std::min(MAX_VIEWPORTS, NumViewports);
906+
m_NumViewports = (std::min)(MAX_VIEWPORTS, NumViewports);
907907

908908
Viewport DefaultVP{RTWidth, RTHeight};
909909
// If no viewports are specified, use default viewport
@@ -956,7 +956,7 @@ inline void DeviceContextBase<ImplementationTraits>::SetScissorRects(
956956
}
957957

958958
DEV_CHECK_ERR(NumRects < MAX_VIEWPORTS, "Number of scissor rects (", NumRects, ") exceeds the limit (", MAX_VIEWPORTS, ")");
959-
m_NumScissorRects = std::min(MAX_VIEWPORTS, NumRects);
959+
m_NumScissorRects = (std::min)(MAX_VIEWPORTS, NumRects);
960960

961961
for (Uint32 sr = 0; sr < m_NumScissorRects; ++sr)
962962
{
@@ -1011,18 +1011,18 @@ inline bool DeviceContextBase<ImplementationTraits>::SetRenderTargets(const SetR
10111011
// Use this RTV to set the render target size
10121012
if (m_FramebufferWidth == 0)
10131013
{
1014-
m_FramebufferWidth = std::max(TexDesc.Width >> RTVDesc.MostDetailedMip, 1U);
1015-
m_FramebufferHeight = std::max(TexDesc.Height >> RTVDesc.MostDetailedMip, 1U);
1014+
m_FramebufferWidth = (std::max)(TexDesc.Width >> RTVDesc.MostDetailedMip, 1U);
1015+
m_FramebufferHeight = (std::max)(TexDesc.Height >> RTVDesc.MostDetailedMip, 1U);
10161016
m_FramebufferSlices = RTVDesc.NumArraySlices;
10171017
m_FramebufferSamples = TexDesc.SampleCount;
10181018
}
10191019
else
10201020
{
10211021
#ifdef DILIGENT_DEVELOPMENT
1022-
DEV_CHECK_ERR(m_FramebufferWidth == std::max(TexDesc.Width >> RTVDesc.MostDetailedMip, 1U),
1023-
"Render target width (", std::max(TexDesc.Width >> RTVDesc.MostDetailedMip, 1U), ") specified by RTV '", RTVDesc.Name, "' is inconsistent with the width of previously bound render targets (", m_FramebufferWidth, ")");
1024-
DEV_CHECK_ERR(m_FramebufferHeight == std::max(TexDesc.Height >> RTVDesc.MostDetailedMip, 1U),
1025-
"Render target height (", std::max(TexDesc.Height >> RTVDesc.MostDetailedMip, 1U), ") specified by RTV '", RTVDesc.Name, "' is inconsistent with the height of previously bound render targets (", m_FramebufferHeight, ")");
1022+
DEV_CHECK_ERR(m_FramebufferWidth == (std::max)(TexDesc.Width >> RTVDesc.MostDetailedMip, 1U),
1023+
"Render target width (", (std::max)(TexDesc.Width >> RTVDesc.MostDetailedMip, 1U), ") specified by RTV '", RTVDesc.Name, "' is inconsistent with the width of previously bound render targets (", m_FramebufferWidth, ")");
1024+
DEV_CHECK_ERR(m_FramebufferHeight == (std::max)(TexDesc.Height >> RTVDesc.MostDetailedMip, 1U),
1025+
"Render target height (", (std::max)(TexDesc.Height >> RTVDesc.MostDetailedMip, 1U), ") specified by RTV '", RTVDesc.Name, "' is inconsistent with the height of previously bound render targets (", m_FramebufferHeight, ")");
10261026
DEV_CHECK_ERR(m_FramebufferSlices == RTVDesc.NumArraySlices,
10271027
"The number of slices (", RTVDesc.NumArraySlices, ") specified by RTV '", RTVDesc.Name, "' is inconsistent with the number of slices in previously bound render targets (", m_FramebufferSlices, ")");
10281028
DEV_CHECK_ERR(m_FramebufferSamples == TexDesc.SampleCount,
@@ -1054,18 +1054,18 @@ inline bool DeviceContextBase<ImplementationTraits>::SetRenderTargets(const SetR
10541054
// Use depth stencil size to set render target size
10551055
if (m_FramebufferWidth == 0)
10561056
{
1057-
m_FramebufferWidth = std::max(TexDesc.Width >> DSVDesc.MostDetailedMip, 1U);
1058-
m_FramebufferHeight = std::max(TexDesc.Height >> DSVDesc.MostDetailedMip, 1U);
1057+
m_FramebufferWidth = (std::max)(TexDesc.Width >> DSVDesc.MostDetailedMip, 1U);
1058+
m_FramebufferHeight = (std::max)(TexDesc.Height >> DSVDesc.MostDetailedMip, 1U);
10591059
m_FramebufferSlices = DSVDesc.NumArraySlices;
10601060
m_FramebufferSamples = TexDesc.SampleCount;
10611061
}
10621062
else
10631063
{
10641064
#ifdef DILIGENT_DEVELOPMENT
1065-
DEV_CHECK_ERR(m_FramebufferWidth == std::max(TexDesc.Width >> DSVDesc.MostDetailedMip, 1U),
1066-
"Depth-stencil target width (", std::max(TexDesc.Width >> DSVDesc.MostDetailedMip, 1U), ") specified by DSV '", DSVDesc.Name, "' is inconsistent with the width of previously bound render targets (", m_FramebufferWidth, ")");
1067-
DEV_CHECK_ERR(m_FramebufferHeight == std::max(TexDesc.Height >> DSVDesc.MostDetailedMip, 1U),
1068-
"Depth-stencil target height (", std::max(TexDesc.Height >> DSVDesc.MostDetailedMip, 1U), ") specified by DSV '", DSVDesc.Name, "' is inconsistent with the height of previously bound render targets (", m_FramebufferHeight, ")");
1065+
DEV_CHECK_ERR(m_FramebufferWidth == (std::max)(TexDesc.Width >> DSVDesc.MostDetailedMip, 1U),
1066+
"Depth-stencil target width (", (std::max)(TexDesc.Width >> DSVDesc.MostDetailedMip, 1U), ") specified by DSV '", DSVDesc.Name, "' is inconsistent with the width of previously bound render targets (", m_FramebufferWidth, ")");
1067+
DEV_CHECK_ERR(m_FramebufferHeight == (std::max)(TexDesc.Height >> DSVDesc.MostDetailedMip, 1U),
1068+
"Depth-stencil target height (", (std::max)(TexDesc.Height >> DSVDesc.MostDetailedMip, 1U), ") specified by DSV '", DSVDesc.Name, "' is inconsistent with the height of previously bound render targets (", m_FramebufferHeight, ")");
10691069
DEV_CHECK_ERR(m_FramebufferSlices == DSVDesc.NumArraySlices,
10701070
"The number of slices (", DSVDesc.NumArraySlices, ") specified by DSV '", DSVDesc.Name, "' is inconsistent with the number of slices in previously bound render targets (", m_FramebufferSlices, ")");
10711071
DEV_CHECK_ERR(m_FramebufferSamples == TexDesc.SampleCount,
@@ -1113,8 +1113,8 @@ inline bool DeviceContextBase<ImplementationTraits>::SetRenderTargets(const SetR
11131113
DEV_ERROR("IDeviceContext::SetRenderTargets: unexpected shading rate format");
11141114
}
11151115

1116-
const auto Width = std::max(TexDesc.Width >> ViewDesc.MostDetailedMip, 1u);
1117-
const auto Height = std::max(TexDesc.Height >> ViewDesc.MostDetailedMip, 1u);
1116+
const auto Width = (std::max)(TexDesc.Width >> ViewDesc.MostDetailedMip, 1u);
1117+
const auto Height = (std::max)(TexDesc.Height >> ViewDesc.MostDetailedMip, 1u);
11181118
const auto MinWidth = (m_FramebufferWidth + SRProps.MaxTileSize[0] - 1) / SRProps.MaxTileSize[0];
11191119
const auto MinHeight = (m_FramebufferHeight + SRProps.MaxTileSize[1] - 1) / SRProps.MaxTileSize[1];
11201120
DEV_CHECK_ERR(Width >= MinWidth,
@@ -2202,14 +2202,14 @@ inline Uint32 GetPrimitiveCount(PRIMITIVE_TOPOLOGY Topology, Uint32 Elements)
22022202

22032203
// clang-format off
22042204
case PRIMITIVE_TOPOLOGY_TRIANGLE_LIST: return Elements / 3;
2205-
case PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP: return std::max(Elements, 2u) - 2;
2205+
case PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP: return (std::max)(Elements, 2u) - 2;
22062206
case PRIMITIVE_TOPOLOGY_POINT_LIST: return Elements;
22072207
case PRIMITIVE_TOPOLOGY_LINE_LIST: return Elements / 2;
2208-
case PRIMITIVE_TOPOLOGY_LINE_STRIP: return std::max(Elements, 1u) - 1;
2208+
case PRIMITIVE_TOPOLOGY_LINE_STRIP: return (std::max)(Elements, 1u) - 1;
22092209
case PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_ADJ: return Elements / 6;
2210-
case PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_ADJ: return std::max(Elements, 4u) - 4;
2210+
case PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_ADJ: return (std::max)(Elements, 4u) - 4;
22112211
case PRIMITIVE_TOPOLOGY_LINE_LIST_ADJ: return Elements / 4;
2212-
case PRIMITIVE_TOPOLOGY_LINE_STRIP_ADJ: return std::max(Elements, 3u) - 3;
2212+
case PRIMITIVE_TOPOLOGY_LINE_STRIP_ADJ: return (std::max)(Elements, 3u) - 3;
22132213
// clang-format on
22142214
default: UNEXPECTED("Unexpected primitive topology"); return 0;
22152215
}

Graphics/GraphicsEngine/include/RenderDeviceBase.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class RenderDeviceBase : public ObjectBase<typename EngineImplTraits::RenderDevi
133133
m_AdapterInfo {AdapterInfo},
134134
m_TextureFormatsInfo (TEX_FORMAT_NUM_FORMATS, TextureFormatInfoExt(), STD_ALLOCATOR_RAW_MEM(TextureFormatInfoExt, RawMemAllocator, "Allocator for vector<TextureFormatInfoExt>")),
135135
m_TexFmtInfoInitFlags (TEX_FORMAT_NUM_FORMATS, false, STD_ALLOCATOR_RAW_MEM(bool, RawMemAllocator, "Allocator for vector<bool>")),
136-
m_wpImmediateContexts (std::max(1u, EngineCI.NumImmediateContexts), RefCntWeakPtr<DeviceContextImplType>(), STD_ALLOCATOR_RAW_MEM(RefCntWeakPtr<DeviceContextImplType>, RawMemAllocator, "Allocator for vector<RefCntWeakPtr<DeviceContextImplType>>")),
136+
m_wpImmediateContexts ((std::max)(1u, EngineCI.NumImmediateContexts), RefCntWeakPtr<DeviceContextImplType>(), STD_ALLOCATOR_RAW_MEM(RefCntWeakPtr<DeviceContextImplType>, RawMemAllocator, "Allocator for vector<RefCntWeakPtr<DeviceContextImplType>>")),
137137
m_wpDeferredContexts (EngineCI.NumDeferredContexts, RefCntWeakPtr<DeviceContextImplType>(), STD_ALLOCATOR_RAW_MEM(RefCntWeakPtr<DeviceContextImplType>, RawMemAllocator, "Allocator for vector<RefCntWeakPtr<DeviceContextImplType>>")),
138138
m_RawMemAllocator {RawMemAllocator},
139139
m_TexObjAllocator {RawMemAllocator, sizeof(TextureImplType), 16},
@@ -357,17 +357,17 @@ class RenderDeviceBase : public ObjectBase<typename EngineImplTraits::RenderDevi
357357
}
358358
else if (NumThreads != 0)
359359
{
360-
const Uint32 NumCores = std::max(std::thread::hardware_concurrency(), 1u);
360+
const Uint32 NumCores = (std::max)(std::thread::hardware_concurrency(), 1u);
361361

362362
ThreadPoolCreateInfo ThreadPoolCI;
363363
if (NumThreads == ~0u)
364364
{
365365
// Leave one core for the main thread
366-
ThreadPoolCI.NumThreads = std::max(NumCores, 2u) - 1u;
366+
ThreadPoolCI.NumThreads = (std::max)(NumCores, 2u) - 1u;
367367
}
368368
else
369369
{
370-
ThreadPoolCI.NumThreads = std::min(NumThreads, std::max(NumCores * 4, 128u));
370+
ThreadPoolCI.NumThreads = (std::min)(NumThreads, (std::max)(NumCores * 4, 128u));
371371
}
372372
m_pShaderCompilationThreadPool = CreateThreadPool(ThreadPoolCI);
373373
}

0 commit comments

Comments
 (0)