mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-11-13 11:35:41 +00:00
Switched compile time ifs to if constexpr. (#4119)
This commit is contained in:
@@ -64,7 +64,7 @@ struct Args
|
||||
{
|
||||
m_type = bgfx::RendererType::Direct3D12;
|
||||
}
|
||||
else if (BX_ENABLED(BX_PLATFORM_OSX) )
|
||||
else if constexpr (BX_ENABLED(BX_PLATFORM_OSX) )
|
||||
{
|
||||
if (cmdLine.hasArg("mtl") )
|
||||
{
|
||||
|
||||
+22
-20
@@ -79,7 +79,7 @@ namespace bgfx
|
||||
|
||||
CallbackStub()
|
||||
{
|
||||
if (BX_ENABLED(BGFX_CONFIG_PROFILER) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_PROFILER) )
|
||||
{
|
||||
m_superluminal.load();
|
||||
}
|
||||
@@ -568,7 +568,7 @@ namespace bgfx
|
||||
|
||||
void dump(const VertexLayout& _layout)
|
||||
{
|
||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_DEBUG) )
|
||||
{
|
||||
BX_TRACE("VertexLayout %08x (%08x), stride %d"
|
||||
, _layout.m_hash
|
||||
@@ -1566,7 +1566,7 @@ namespace bgfx
|
||||
|
||||
void EncoderImpl::submit(ViewId _id, ProgramHandle _program, OcclusionQueryHandle _occlusionQuery, uint32_t _depth, uint8_t _flags)
|
||||
{
|
||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG_UNIFORM) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_DEBUG_UNIFORM) )
|
||||
{
|
||||
m_uniformSet.clear();
|
||||
}
|
||||
@@ -1699,7 +1699,7 @@ namespace bgfx
|
||||
|
||||
void EncoderImpl::dispatch(ViewId _id, ProgramHandle _handle, uint32_t _numX, uint32_t _numY, uint32_t _numZ, uint8_t _flags)
|
||||
{
|
||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG_UNIFORM) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_DEBUG_UNIFORM) )
|
||||
{
|
||||
m_uniformSet.clear();
|
||||
}
|
||||
@@ -1914,7 +1914,7 @@ namespace bgfx
|
||||
|
||||
RenderFrame::Enum renderFrame(int32_t _msecs)
|
||||
{
|
||||
if (BX_ENABLED(BGFX_CONFIG_MULTITHREADED) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_MULTITHREADED) )
|
||||
{
|
||||
if (s_renderFrameCalled)
|
||||
{
|
||||
@@ -1943,9 +1943,11 @@ namespace bgfx
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
BX_ASSERT(false, "This call only makes sense if used with multi-threaded renderer.");
|
||||
return RenderFrame::NoContext;
|
||||
else
|
||||
{
|
||||
BX_ASSERT(false, "This call only makes sense if used with multi-threaded renderer.");
|
||||
return RenderFrame::NoContext;
|
||||
}
|
||||
}
|
||||
|
||||
const uint32_t g_uniformTypeSize[] =
|
||||
@@ -2695,7 +2697,7 @@ namespace bgfx
|
||||
m_submit->m_transientIb = createTransientIndexBuffer(_init.limits.maxTransientIbSize);
|
||||
frame();
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_MULTITHREADED) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_MULTITHREADED) )
|
||||
{
|
||||
m_submit->m_transientVb = createTransientVertexBuffer(_init.limits.maxTransientVbSize);
|
||||
m_submit->m_transientIb = createTransientIndexBuffer(_init.limits.maxTransientIbSize);
|
||||
@@ -2732,7 +2734,7 @@ namespace bgfx
|
||||
m_videoDecode.shutdown();
|
||||
frame();
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_MULTITHREADED) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_MULTITHREADED) )
|
||||
{
|
||||
destroyTransientVertexBuffer(m_submit->m_transientVb);
|
||||
destroyTransientIndexBuffer(m_submit->m_transientIb);
|
||||
@@ -2800,7 +2802,7 @@ namespace bgfx
|
||||
m_viewNames.destroy();
|
||||
m_submit->destroy();
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_DEBUG) )
|
||||
{
|
||||
#define CHECK_HANDLE_LEAK(_name, _handleAlloc) \
|
||||
BX_MACRO_BLOCK_BEGIN \
|
||||
@@ -3360,7 +3362,7 @@ namespace bgfx
|
||||
uint32_t nextFrameNum = m_render->m_frameNum + 1;
|
||||
m_submit->start(nextFrameNum);
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG_TEXT) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_DEBUG_TEXT) )
|
||||
{
|
||||
m_submit->m_textVideoMem->resize(
|
||||
m_render->m_textVideoMem->m_small
|
||||
@@ -3815,7 +3817,7 @@ namespace bgfx
|
||||
|
||||
score += RendererType::Noop != renderer ? 1 : 0;
|
||||
|
||||
if (BX_ENABLED(BX_PLATFORM_WINDOWS) )
|
||||
if constexpr (BX_ENABLED(BX_PLATFORM_WINDOWS) )
|
||||
{
|
||||
if (windowsVersionIs(Condition::GreaterEqual, 0x0602) )
|
||||
{
|
||||
@@ -3832,7 +3834,7 @@ namespace bgfx
|
||||
score += RendererType::Direct3D12 == renderer ? -100 : 0;
|
||||
}
|
||||
}
|
||||
else if (BX_ENABLED(BX_PLATFORM_LINUX) )
|
||||
else if constexpr (BX_ENABLED(BX_PLATFORM_LINUX) )
|
||||
{
|
||||
score += RendererType::Vulkan == renderer ? 50 : 0;
|
||||
score += RendererType::OpenGL == renderer ? 40 : 0;
|
||||
@@ -3840,16 +3842,16 @@ namespace bgfx
|
||||
score += RendererType::Direct3D12 == renderer ? 20 : 0;
|
||||
score += RendererType::Direct3D11 == renderer ? 10 : 0;
|
||||
}
|
||||
else if (BX_ENABLED(BX_PLATFORM_OSX) )
|
||||
else if constexpr (BX_ENABLED(BX_PLATFORM_OSX) )
|
||||
{
|
||||
score += RendererType::Metal == renderer ? 20 : 0;
|
||||
score += RendererType::Vulkan == renderer ? 10 : 0;
|
||||
}
|
||||
else if (BX_ENABLED(BX_PLATFORM_IOS) || BX_ENABLED(BX_PLATFORM_VISIONOS))
|
||||
else if constexpr (BX_ENABLED(BX_PLATFORM_IOS) || BX_ENABLED(BX_PLATFORM_VISIONOS))
|
||||
{
|
||||
score += RendererType::Metal == renderer ? 20 : 0;
|
||||
}
|
||||
else if (BX_ENABLED(0
|
||||
else if constexpr (BX_ENABLED(0
|
||||
|| BX_PLATFORM_ANDROID
|
||||
|| BX_PLATFORM_EMSCRIPTEN
|
||||
|| BX_PLATFORM_RPI
|
||||
@@ -3857,11 +3859,11 @@ namespace bgfx
|
||||
{
|
||||
score += RendererType::OpenGLES == renderer ? 20 : 0;
|
||||
}
|
||||
else if (BX_ENABLED(BX_PLATFORM_PS4) )
|
||||
else if constexpr (BX_ENABLED(BX_PLATFORM_PS4) )
|
||||
{
|
||||
score += RendererType::Gnm == renderer ? 20 : 0;
|
||||
}
|
||||
else if (BX_ENABLED(0
|
||||
else if constexpr (BX_ENABLED(0
|
||||
|| BX_PLATFORM_XBOXONE
|
||||
|| BX_PLATFORM_WINRT
|
||||
) )
|
||||
@@ -7298,7 +7300,7 @@ namespace bgfx
|
||||
{
|
||||
BX_ASSERT(checkView(_id), "Invalid view id: %d", _id);
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_DEBUG) )
|
||||
{
|
||||
const uint8_t index[] = { _0, _1, _2, _3, _4, _5, _6, _7 };
|
||||
|
||||
|
||||
+13
-13
@@ -1932,7 +1932,7 @@ namespace bgfx
|
||||
{
|
||||
m_capacity = bx::min<uint32_t>(_numMax, BGFX_CONFIG_MAX_MATRIX_CACHE);
|
||||
|
||||
if (!BX_ENABLED(BGFX_CONFIG_DYNAMIC_FRAME_STORAGE) )
|
||||
if constexpr (!BX_ENABLED(BGFX_CONFIG_DYNAMIC_FRAME_STORAGE) )
|
||||
{
|
||||
_numReserved = m_capacity;
|
||||
_numPeakFrames = 0;
|
||||
@@ -4093,7 +4093,7 @@ namespace bgfx
|
||||
|
||||
bool queue(Ty _handle)
|
||||
{
|
||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_DEBUG) )
|
||||
{
|
||||
if (isQueued(_handle) )
|
||||
{
|
||||
@@ -4360,7 +4360,7 @@ namespace bgfx
|
||||
reset();
|
||||
start(0);
|
||||
m_textVideoMem = NULL;
|
||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG_TEXT) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_DEBUG_TEXT) )
|
||||
{
|
||||
m_textVideoMem = BX_NEW(g_allocator, TextVideoMem);
|
||||
}
|
||||
@@ -4706,12 +4706,12 @@ namespace bgfx
|
||||
m_cpuTimeEnd = bx::getHPCounter();
|
||||
}
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG_OCCLUSION) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_DEBUG_OCCLUSION) )
|
||||
{
|
||||
m_occlusionQuerySet.clear();
|
||||
}
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG_UNIFORM) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_DEBUG_UNIFORM) )
|
||||
{
|
||||
m_uniformSet.clear();
|
||||
}
|
||||
@@ -4785,7 +4785,7 @@ namespace bgfx
|
||||
|
||||
void setUniform(UniformType::Enum _type, UniformHandle _handle, const void* _value, uint16_t _num)
|
||||
{
|
||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG_UNIFORM) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_DEBUG_UNIFORM) )
|
||||
{
|
||||
BX_ASSERT(m_uniformSet.end() == m_uniformSet.find(_handle.idx)
|
||||
, "Uniform %d (%s) was already set for this draw call."
|
||||
@@ -4809,7 +4809,7 @@ namespace bgfx
|
||||
|
||||
void setUniformRef(UniformType::Enum _type, UniformHandle _handle, const void* _ptr, uint16_t _num)
|
||||
{
|
||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG_UNIFORM) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_DEBUG_UNIFORM) )
|
||||
{
|
||||
BX_ASSERT(m_uniformSet.end() == m_uniformSet.find(_handle.idx)
|
||||
, "Uniform %d (%s) was already set for this draw call."
|
||||
@@ -5204,7 +5204,7 @@ namespace bgfx
|
||||
|
||||
void discard(uint8_t _flags)
|
||||
{
|
||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG_UNIFORM) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_DEBUG_UNIFORM) )
|
||||
{
|
||||
m_uniformSet.clear();
|
||||
}
|
||||
@@ -6308,7 +6308,7 @@ namespace bgfx
|
||||
{
|
||||
BGFX_MUTEX_SCOPE(m_resourceApiLock);
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG_TEXT) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_DEBUG_TEXT) )
|
||||
{
|
||||
uint16_t width;
|
||||
uint16_t height;
|
||||
@@ -6327,7 +6327,7 @@ namespace bgfx
|
||||
{
|
||||
BGFX_MUTEX_SCOPE(m_resourceApiLock);
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG_TEXT) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_DEBUG_TEXT) )
|
||||
{
|
||||
m_submit->m_textVideoMem->printfVargs(_x, _y, _attr, _format, _argList);
|
||||
}
|
||||
@@ -6337,7 +6337,7 @@ namespace bgfx
|
||||
{
|
||||
BGFX_MUTEX_SCOPE(m_resourceApiLock);
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG_TEXT) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_DEBUG_TEXT) )
|
||||
{
|
||||
m_submit->m_textVideoMem->image(_x, _y, _width, _height, _data, _pitch);
|
||||
}
|
||||
@@ -6353,7 +6353,7 @@ namespace bgfx
|
||||
stats.height = uint16_t(resolution.height);
|
||||
stats.textWidth = 0;
|
||||
stats.textHeight = 0;
|
||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG_TEXT) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_DEBUG_TEXT) )
|
||||
{
|
||||
const TextVideoMem* tvm = m_submit->m_textVideoMem;
|
||||
stats.textWidth = tvm->m_width;
|
||||
@@ -7419,7 +7419,7 @@ namespace bgfx
|
||||
|
||||
void setDebugNameForHandle(Handle _handle, const bx::StringView& _name = "")
|
||||
{
|
||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_DEBUG) )
|
||||
{
|
||||
setNameForHandle(_handle, _name);
|
||||
}
|
||||
|
||||
@@ -386,7 +386,7 @@ WL_EGL_IMPORT
|
||||
m_colorspaceSupport = !bx::findIdentifierMatch(extensions, "EGL_KHR_gl_colorspace").isEmpty();
|
||||
m_srgb = 0 != (_swapChain.flags & BGFX_SWAP_CHAIN_SRGB_BACKBUFFER);
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) )
|
||||
{
|
||||
EGLBoolean ok = eglBindAPI(EGL_OPENGL_API);
|
||||
|
||||
@@ -692,7 +692,7 @@ WL_EGL_IMPORT
|
||||
# else
|
||||
if (hasEglKhrCreateContext)
|
||||
{
|
||||
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) )
|
||||
{
|
||||
bx::write(&writer, EGLint(EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR), bx::ErrorAssert{});
|
||||
bx::write(&writer, EGLint(EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR), bx::ErrorAssert{});
|
||||
@@ -781,7 +781,7 @@ WL_EGL_IMPORT
|
||||
m_surface = eglGetCurrentSurface(EGL_DRAW);
|
||||
m_readSurface = eglGetCurrentSurface(EGL_READ);
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) )
|
||||
{
|
||||
EGLBoolean ok = eglBindAPI(EGL_OPENGL_API);
|
||||
|
||||
@@ -847,7 +847,7 @@ WL_EGL_IMPORT
|
||||
|
||||
if (hasEglKhrCreateContext)
|
||||
{
|
||||
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) )
|
||||
{
|
||||
bx::write(&writer, EGLint(EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR), bx::ErrorAssert{});
|
||||
bx::write(&writer, EGLint(EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR), bx::ErrorAssert{});
|
||||
|
||||
+10
-10
@@ -777,9 +777,9 @@ namespace bgfx { namespace d3d11
|
||||
|
||||
#if USE_D3D11_DYNAMIC_LIB
|
||||
static PFN_D3D11_CREATE_DEVICE D3D11CreateDevice;
|
||||
static PFN_D3DPERF_SET_MARKER D3DPERF_SetMarker;
|
||||
static PFN_D3DPERF_BEGIN_EVENT D3DPERF_BeginEvent;
|
||||
static PFN_D3DPERF_END_EVENT D3DPERF_EndEvent;
|
||||
[[maybe_unused]] static PFN_D3DPERF_SET_MARKER D3DPERF_SetMarker;
|
||||
[[maybe_unused]] static PFN_D3DPERF_BEGIN_EVENT D3DPERF_BeginEvent;
|
||||
[[maybe_unused]] static PFN_D3DPERF_END_EVENT D3DPERF_EndEvent;
|
||||
#endif // USE_D3D11_DYNAMIC_LIB
|
||||
|
||||
int WINAPI d3d11Annotation_BeginEvent(DWORD _color, LPCWSTR _name);
|
||||
@@ -958,7 +958,7 @@ namespace bgfx { namespace d3d11
|
||||
|
||||
m_d3d9Dll = NULL;
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) )
|
||||
{
|
||||
// D3D11_1.h has ID3DUserDefinedAnnotation
|
||||
// https://web.archive.org/web/20190207230424/https://docs.microsoft.com/en-us/windows/desktop/api/d3d11_1/nn-d3d11_1-id3duserdefinedannotation
|
||||
@@ -1258,7 +1258,7 @@ namespace bgfx { namespace d3d11
|
||||
}
|
||||
|
||||
#if USE_D3D11_DYNAMIC_LIB
|
||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) )
|
||||
{
|
||||
HRESULT hr = m_deviceCtx->QueryInterface(IID_ID3DUserDefinedAnnotation, (void**)&m_annotation);
|
||||
|
||||
@@ -1380,7 +1380,7 @@ namespace bgfx { namespace d3d11
|
||||
|
||||
if (DXGI_FORMAT_UNKNOWN != fmt)
|
||||
{
|
||||
if (BX_ENABLED(BX_PLATFORM_LINUX || BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT) )
|
||||
if constexpr (BX_ENABLED(BX_PLATFORM_LINUX || BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT) )
|
||||
{
|
||||
D3D11_FEATURE_DATA_FORMAT_SUPPORT data;
|
||||
data.InFormat = fmt;
|
||||
@@ -1557,7 +1557,7 @@ namespace bgfx { namespace d3d11
|
||||
|
||||
if (DXGI_FORMAT_UNKNOWN != fmtSrgb)
|
||||
{
|
||||
if (BX_ENABLED(BX_PLATFORM_LINUX || BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT) )
|
||||
if constexpr (BX_ENABLED(BX_PLATFORM_LINUX || BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT) )
|
||||
{
|
||||
struct D3D11_FEATURE_DATA_FORMAT_SUPPORT
|
||||
{
|
||||
@@ -2247,7 +2247,7 @@ namespace bgfx { namespace d3d11
|
||||
|
||||
void setMarker(const char* _marker, uint16_t _len) override
|
||||
{
|
||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) )
|
||||
{
|
||||
uint32_t size = _len*sizeof(wchar_t);
|
||||
wchar_t* name = (wchar_t*)BX_STACK_ALLOC(size+2);
|
||||
@@ -3365,7 +3365,7 @@ namespace bgfx { namespace d3d11
|
||||
|
||||
void commitTextureStage()
|
||||
{
|
||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_DEBUG) )
|
||||
{
|
||||
quietValidation();
|
||||
}
|
||||
@@ -7720,7 +7720,7 @@ namespace bgfx { namespace d3d11
|
||||
}
|
||||
}
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_DEBUG) )
|
||||
{
|
||||
// Quiet validation: Resource being set to CS UnorderedAccessView slot 0 is still bound on input!
|
||||
deviceCtx->CSSetShaderResources(0, maxComputeBindings, s_zero.m_srv);
|
||||
|
||||
@@ -57,7 +57,7 @@ BX_PRAGMA_DIAGNOSTIC_POP()
|
||||
|
||||
#define BGFX_D3D11_PROFILER_BEGIN(_view, _abgr) \
|
||||
BX_MACRO_BLOCK_BEGIN \
|
||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) ) \
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) ) \
|
||||
{ \
|
||||
wchar_t viewNameW[BGFX_CONFIG_MAX_VIEW_NAME]; \
|
||||
PIX_BEGINEVENT(_abgr, toViewNameW(viewNameW, viewName) ); \
|
||||
|
||||
@@ -3067,7 +3067,7 @@ namespace bgfx { namespace d3d12
|
||||
{
|
||||
BX_UNUSED(_len);
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) )
|
||||
{
|
||||
PIX3_SETMARKER(m_commandList, kColorMarker, _marker);
|
||||
}
|
||||
@@ -8502,7 +8502,7 @@ namespace bgfx { namespace d3d12
|
||||
, rtvHandle
|
||||
);
|
||||
|
||||
if (BX_ENABLED(BX_PLATFORM_XBOXONE) )
|
||||
if constexpr (BX_ENABLED(BX_PLATFORM_XBOXONE) )
|
||||
{
|
||||
ID3D12Resource* resource = m_backBufferColor[ii];
|
||||
|
||||
|
||||
+29
-27
@@ -1250,7 +1250,7 @@ namespace bgfx { namespace gl
|
||||
|
||||
void lazyEnableVertexAttribArray(GLuint index)
|
||||
{
|
||||
if (BX_ENABLED(BX_PLATFORM_EMSCRIPTEN) )
|
||||
if constexpr (BX_ENABLED(BX_PLATFORM_EMSCRIPTEN) )
|
||||
{
|
||||
if (index >= 64)
|
||||
{
|
||||
@@ -1272,7 +1272,7 @@ namespace bgfx { namespace gl
|
||||
|
||||
void lazyDisableVertexAttribArray(GLuint index)
|
||||
{
|
||||
if (BX_ENABLED(BX_PLATFORM_EMSCRIPTEN) )
|
||||
if constexpr (BX_ENABLED(BX_PLATFORM_EMSCRIPTEN) )
|
||||
{
|
||||
if (index >= 64)
|
||||
{
|
||||
@@ -1294,7 +1294,7 @@ namespace bgfx { namespace gl
|
||||
|
||||
void applyLazyEnabledVertexAttributes()
|
||||
{
|
||||
if (BX_ENABLED(BX_PLATFORM_EMSCRIPTEN) )
|
||||
if constexpr (BX_ENABLED(BX_PLATFORM_EMSCRIPTEN) )
|
||||
{
|
||||
while (s_vertexAttribArraysPendingDisable)
|
||||
{
|
||||
@@ -2358,7 +2358,7 @@ namespace bgfx { namespace gl
|
||||
m_version = getGLString(GL_VERSION);
|
||||
m_glslVersion = getGLString(GL_SHADING_LANGUAGE_VERSION);
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES) )
|
||||
{
|
||||
const bx::StringView essl = bx::strFind(m_glslVersion, "GLSL ES ");
|
||||
|
||||
@@ -2410,7 +2410,7 @@ namespace bgfx { namespace gl
|
||||
}
|
||||
}
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_DEBUG) )
|
||||
{
|
||||
#define GL_GET(_pname, _min) BX_TRACE(" " #_pname " %d (min: %d)", glGet(_pname), _min)
|
||||
BX_TRACE("Defaults:");
|
||||
@@ -2465,7 +2465,7 @@ namespace bgfx { namespace gl
|
||||
s_extension[Extension::KHR_debug].m_initialize = false;
|
||||
}
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_RENDERER_USE_EXTENSIONS) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_RENDERER_USE_EXTENSIONS) )
|
||||
{
|
||||
const char* extensions = (const char*)glGetString(GL_EXTENSIONS);
|
||||
getGlError(); // ignore error if glGetString returns NULL.
|
||||
@@ -2600,7 +2600,7 @@ namespace bgfx { namespace gl
|
||||
s_textureFormat[TextureFormat::PTC22].m_supported |= ptc2Supported;
|
||||
s_textureFormat[TextureFormat::PTC24].m_supported |= ptc2Supported;
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES) )
|
||||
{
|
||||
setTextureFormat(TextureFormat::R16F, GL_R16F, GL_RED, 0x140B /* == GL_HALF_FLOAT, but bgfx overwrites it globally with GL_HALF_FLOAT_OES */);
|
||||
setTextureFormat(TextureFormat::RG16F, GL_RG16F, GL_RG, 0x140B /* == GL_HALF_FLOAT, but bgfx overwrites it globally with GL_HALF_FLOAT_OES */);
|
||||
@@ -2633,7 +2633,7 @@ namespace bgfx { namespace gl
|
||||
setTextureFormatSrgb(TextureFormat::R5G6B5, GL_ZERO, GL_BGR);
|
||||
}
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL)
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL)
|
||||
|| BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES))
|
||||
{
|
||||
setTextureFormat(TextureFormat::R8I, GL_R8I, GL_RED_INTEGER, GL_BYTE);
|
||||
@@ -2652,7 +2652,7 @@ namespace bgfx { namespace gl
|
||||
|| s_extension[Extension::IMG_texture_format_BGRA8888 ].m_supported
|
||||
|| s_extension[Extension::APPLE_texture_format_BGRA8888].m_supported)
|
||||
{
|
||||
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) )
|
||||
{
|
||||
m_readPixelsFmt = GL_BGRA;
|
||||
}
|
||||
@@ -2681,7 +2681,7 @@ namespace bgfx { namespace gl
|
||||
}
|
||||
}
|
||||
|
||||
if (BX_ENABLED(BX_PLATFORM_EMSCRIPTEN) )
|
||||
if constexpr (BX_ENABLED(BX_PLATFORM_EMSCRIPTEN) )
|
||||
{
|
||||
// OpenGL ES does not have reversed BGRA4 and BGR5A1 support.
|
||||
setTextureFormat(TextureFormat::BGRA4, GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4);
|
||||
@@ -2732,7 +2732,7 @@ namespace bgfx { namespace gl
|
||||
}
|
||||
}
|
||||
|
||||
if (BX_ENABLED(0) )
|
||||
if constexpr (BX_ENABLED(0) )
|
||||
{
|
||||
// Disable all compressed texture formats. For testing only.
|
||||
for (uint32_t ii = 0; ii < TextureFormat::Unknown; ++ii)
|
||||
@@ -2903,7 +2903,7 @@ namespace bgfx { namespace gl
|
||||
: 0
|
||||
;
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES) )
|
||||
{
|
||||
glPolygonMode = s_extension[Extension::NV_polygon_mode].m_supported
|
||||
? glPolygonModeNV
|
||||
@@ -2995,7 +2995,7 @@ namespace bgfx { namespace gl
|
||||
);
|
||||
}
|
||||
|
||||
if (!BX_ENABLED(BGFX_CONFIG_GL_NORMALIZE_NDC_CONVENTIONS) )
|
||||
if constexpr (!BX_ENABLED(BGFX_CONFIG_GL_NORMALIZE_NDC_CONVENTIONS) )
|
||||
{
|
||||
g_caps.homogeneousDepth = true;
|
||||
g_caps.originBottomLeft = true;
|
||||
@@ -3070,7 +3070,7 @@ namespace bgfx { namespace gl
|
||||
|
||||
g_caps.supported |= m_glctx.getCaps();
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES) )
|
||||
{
|
||||
m_srgbWriteControlSupport = s_extension[Extension::EXT_sRGB_write_control].m_supported;
|
||||
|
||||
@@ -3272,12 +3272,14 @@ namespace bgfx { namespace gl
|
||||
|
||||
RendererType::Enum getRendererType() const override
|
||||
{
|
||||
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) )
|
||||
{
|
||||
return RendererType::OpenGL;
|
||||
}
|
||||
|
||||
return RendererType::OpenGLES;
|
||||
else
|
||||
{
|
||||
return RendererType::OpenGLES;
|
||||
}
|
||||
}
|
||||
|
||||
const char* getRendererName() const override
|
||||
@@ -4404,7 +4406,7 @@ namespace bgfx { namespace gl
|
||||
GL_CHECK(glGenFramebuffers(1, &m_msaaBackBufferFbo) );
|
||||
GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, m_msaaBackBufferFbo) );
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES))
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES))
|
||||
{
|
||||
GL_CHECK(glGenTextures(BX_COUNTOF(m_msaaBackBufferTextures), m_msaaBackBufferTextures) );
|
||||
GL_CHECK(glBindTexture(GL_TEXTURE_2D, m_msaaBackBufferTextures[0]) );
|
||||
@@ -4570,7 +4572,7 @@ namespace bgfx { namespace gl
|
||||
GL_CHECK(glDeleteFramebuffers(1, &m_msaaBackBufferFbo) );
|
||||
m_msaaBackBufferFbo = 0;
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES))
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES))
|
||||
{
|
||||
if (0 != m_msaaBackBufferTextures[0])
|
||||
{
|
||||
@@ -4613,7 +4615,7 @@ namespace bgfx { namespace gl
|
||||
: GL_LINEAR
|
||||
;
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES))
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES))
|
||||
{
|
||||
GL_CHECK(glUseProgram(m_msaaBlitProgram) );
|
||||
GL_CHECK(glActiveTexture(GL_TEXTURE0) );
|
||||
@@ -4735,7 +4737,7 @@ namespace bgfx { namespace gl
|
||||
GL_CHECK(glSamplerParameteri(sampler, GL_TEXTURE_MAG_FILTER, magFilter) );
|
||||
GL_CHECK(glSamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, minFilter) );
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) )
|
||||
{
|
||||
GL_CHECK(glSamplerParameterf(sampler, GL_TEXTURE_LOD_BIAS, float(BGFX_CONFIG_MIP_LOD_BIAS) ) );
|
||||
}
|
||||
@@ -7365,12 +7367,12 @@ namespace bgfx { namespace gl
|
||||
GL_CHECK(glTexParameteri(target, GL_TEXTURE_MAG_FILTER, magFilter) );
|
||||
GL_CHECK(glTexParameteri(target, GL_TEXTURE_MIN_FILTER, minFilter) );
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) )
|
||||
{
|
||||
GL_CHECK(glTexParameterf(target, GL_TEXTURE_LOD_BIAS, float(BGFX_CONFIG_MIP_LOD_BIAS) ) );
|
||||
}
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL)
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL)
|
||||
|| BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES >= 30) )
|
||||
{
|
||||
GL_CHECK(glTexParameterf(target, GL_TEXTURE_MIN_LOD, float(_lodMin) * 0.25f) );
|
||||
@@ -7909,7 +7911,7 @@ namespace bgfx { namespace gl
|
||||
char* temp = (char*)BX_STACK_ALLOC(tempLen);
|
||||
bx::StaticMemoryBlockWriter writer(temp, tempLen);
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES) )
|
||||
{
|
||||
const bool cubeArray = !bx::strFind(code, "CubeArray").isEmpty();
|
||||
|
||||
@@ -8457,7 +8459,7 @@ namespace bgfx { namespace gl
|
||||
GL_CHECK(glBindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo[0]) );
|
||||
GL_CHECK(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0) );
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES) )
|
||||
{
|
||||
GL_CHECK(glUseProgram(s_renderGL->m_msaaBlitProgram) );
|
||||
GL_CHECK(glActiveTexture(GL_TEXTURE0) );
|
||||
@@ -8557,7 +8559,7 @@ namespace bgfx { namespace gl
|
||||
|
||||
GL_CHECK(glReadBuffer(GL_COLOR_ATTACHMENT0 + colorIdx) );
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) )
|
||||
{
|
||||
GL_CHECK(glDrawBuffer(GL_COLOR_ATTACHMENT0 + colorIdx) );
|
||||
}
|
||||
@@ -10295,7 +10297,7 @@ namespace bgfx { namespace gl
|
||||
viewState.m_alphaRef = ref/255.0f;
|
||||
}
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) )
|
||||
{
|
||||
if ( (BGFX_STATE_PT_POINTS|BGFX_STATE_POINT_SIZE_MASK) & changedFlags)
|
||||
{
|
||||
|
||||
+2
-2
@@ -1301,7 +1301,7 @@ namespace bgfx { namespace gl
|
||||
template<typename T>
|
||||
bool updateUniformCache(uint32_t loc, const T &value)
|
||||
{
|
||||
if (BX_ENABLED(BGFX_GL_CONFIG_UNIFORM_CACHE) )
|
||||
if constexpr (BX_ENABLED(BGFX_GL_CONFIG_UNIFORM_CACHE) )
|
||||
{
|
||||
// Uniform state cache for various types.
|
||||
stl::unordered_map<uint64_t, T>& uniformCacheMap = getUniformCache<T>();
|
||||
@@ -1331,7 +1331,7 @@ namespace bgfx { namespace gl
|
||||
|
||||
void saveCurrentProgram(GLuint program)
|
||||
{
|
||||
if (BX_ENABLED(BGFX_GL_CONFIG_UNIFORM_CACHE) )
|
||||
if constexpr (BX_ENABLED(BGFX_GL_CONFIG_UNIFORM_CACHE) )
|
||||
{
|
||||
m_currentProgram = program;
|
||||
}
|
||||
|
||||
@@ -1895,7 +1895,7 @@ static_assert(BX_COUNTOF(s_accessNames) == Access::Count, "Invalid s_accessNames
|
||||
{
|
||||
BX_UNUSED(_len);
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) )
|
||||
{
|
||||
m_renderCommandEncoder->insertDebugSignpost(nsstr(_marker) );
|
||||
}
|
||||
@@ -6883,12 +6883,12 @@ static_assert(BX_COUNTOF(s_accessNames) == Access::Count, "Invalid s_accessNames
|
||||
|
||||
MTL_RELEASE(renderPassDescriptor, 0);
|
||||
}
|
||||
else if (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) )
|
||||
else if constexpr (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) )
|
||||
{
|
||||
rce->popDebugGroup();
|
||||
}
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) )
|
||||
{
|
||||
rce->pushDebugGroup(nsstr(viewName) );
|
||||
}
|
||||
@@ -7629,7 +7629,7 @@ static_assert(BX_COUNTOF(s_accessNames) == Access::Count, "Invalid s_accessNames
|
||||
}
|
||||
}
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) )
|
||||
{
|
||||
if (0 < _render->m_numRenderItems)
|
||||
{
|
||||
|
||||
+5
-5
@@ -477,7 +477,7 @@ VK_IMPORT_DEVICE
|
||||
bool updateExtension(const char* _name, uint32_t _version, bool _instanceExt, Extension _extensions[Extension::Count])
|
||||
{
|
||||
bool supported = false;
|
||||
if (BX_ENABLED(BGFX_CONFIG_RENDERER_USE_EXTENSIONS) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_RENDERER_USE_EXTENSIONS) )
|
||||
{
|
||||
const bx::StringView ext(_name);
|
||||
for (uint32_t ii = 0; ii < Extension::Count; ++ii)
|
||||
@@ -719,7 +719,7 @@ VK_IMPORT_DEVICE
|
||||
BX_UNUSED(_userData, _size, _allocationType, _allocationScope);
|
||||
}
|
||||
|
||||
static VkAllocationCallbacks s_allocationCb =
|
||||
[[maybe_unused]] static VkAllocationCallbacks s_allocationCb =
|
||||
{
|
||||
NULL,
|
||||
allocationFunction,
|
||||
@@ -1607,7 +1607,7 @@ VK_IMPORT
|
||||
ici.enabledExtensionCount = numEnabledExtensions;
|
||||
ici.ppEnabledExtensionNames = enabledExtension;
|
||||
|
||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_DEBUG) )
|
||||
{
|
||||
// Validation layer is calling freeFunction with pointers that are not allocated
|
||||
// via callback mechanism. This is bug in validation layer, and work-around
|
||||
@@ -2407,7 +2407,7 @@ VK_IMPORT_INSTANCE
|
||||
enabledExtension[numEnabledExtensions++] = VK_KHR_SWAPCHAIN_EXTENSION_NAME;
|
||||
}
|
||||
|
||||
if (BX_ENABLED(BX_PLATFORM_OSX) )
|
||||
if constexpr (BX_ENABLED(BX_PLATFORM_OSX) )
|
||||
{
|
||||
enabledExtension[numEnabledExtensions++] = VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME;
|
||||
}
|
||||
@@ -3258,7 +3258,7 @@ VK_IMPORT_DEVICE
|
||||
|
||||
void setMarker(const char* _marker, uint16_t _len) override
|
||||
{
|
||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) )
|
||||
if constexpr (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) )
|
||||
{
|
||||
BX_UNUSED(_len);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user