diff --git a/include/bgfx/bgfx.h b/include/bgfx/bgfx.h index ba82e66c6..8ecfd74fb 100644 --- a/include/bgfx/bgfx.h +++ b/include/bgfx/bgfx.h @@ -614,6 +614,7 @@ namespace bgfx uint32_t maxDrawCalls; //!< Maximum number of draw calls. uint32_t maxBlits; //!< Maximum number of blit calls. uint32_t maxTextureSize; //!< Maximum texture size. + uint32_t maxTextureLayers; //!< Maximum texture layers. uint32_t maxViews; //!< Maximum number of views. uint32_t maxFrameBuffers; //!< Maximum number of frame buffer handles. uint32_t maxFBAttachments; //!< Maximum number of frame buffer attachments. diff --git a/include/bgfx/c99/bgfx.h b/include/bgfx/c99/bgfx.h index f50099398..c5905f509 100644 --- a/include/bgfx/c99/bgfx.h +++ b/include/bgfx/c99/bgfx.h @@ -495,6 +495,7 @@ typedef struct bgfx_caps_limits uint32_t maxDrawCalls; uint32_t maxBlits; uint32_t maxTextureSize; + uint32_t maxTextureLayers; uint32_t maxViews; uint32_t maxFrameBuffers; uint32_t maxFBAttachments; diff --git a/include/bgfx/defines.h b/include/bgfx/defines.h index 0c2306aa8..344c4d2fd 100644 --- a/include/bgfx/defines.h +++ b/include/bgfx/defines.h @@ -6,7 +6,7 @@ #ifndef BGFX_DEFINES_H_HEADER_GUARD #define BGFX_DEFINES_H_HEADER_GUARD -#define BGFX_API_VERSION UINT32_C(60) +#define BGFX_API_VERSION UINT32_C(61) /// Color RGB/alpha/depth write. When it's not specified write will be disabled. #define BGFX_STATE_RGB_WRITE UINT64_C(0x0000000000000001) //!< Enable RGB write. diff --git a/src/bgfx.cpp b/src/bgfx.cpp index 979dc8231..a0b19c12b 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -1249,6 +1249,7 @@ namespace bgfx LIMITS(maxDrawCalls); LIMITS(maxBlits); LIMITS(maxTextureSize); + LIMITS(maxTextureLayers); LIMITS(maxViews); LIMITS(maxFrameBuffers); LIMITS(maxFBAttachments); @@ -2805,6 +2806,8 @@ namespace bgfx bx::memSet(&g_caps, 0, sizeof(g_caps) ); g_caps.limits.maxDrawCalls = BGFX_CONFIG_MAX_DRAW_CALLS; g_caps.limits.maxBlits = BGFX_CONFIG_MAX_BLIT_ITEMS; + g_caps.limits.maxTextureSize = 0; + g_caps.limits.maxTextureLayers = 1; g_caps.limits.maxViews = BGFX_CONFIG_MAX_VIEWS; g_caps.limits.maxFrameBuffers = BGFX_CONFIG_MAX_FRAME_BUFFERS; g_caps.limits.maxPrograms = BGFX_CONFIG_MAX_PROGRAMS; diff --git a/src/renderer_d3d11.cpp b/src/renderer_d3d11.cpp index f1d519281..06818ad2a 100644 --- a/src/renderer_d3d11.cpp +++ b/src/renderer_d3d11.cpp @@ -1537,6 +1537,7 @@ BX_PRAGMA_DIAGNOSTIC_POP(); { g_caps.supported |= BGFX_CAPS_TEXTURE_COMPARE_ALL; g_caps.limits.maxTextureSize = D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION; + g_caps.limits.maxTextureLayers = D3D11_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION; g_caps.limits.maxFBAttachments = uint8_t(bx::uint32_min( D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT , BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS diff --git a/src/renderer_d3d12.cpp b/src/renderer_d3d12.cpp index 4495a88bf..d2e16489e 100644 --- a/src/renderer_d3d12.cpp +++ b/src/renderer_d3d12.cpp @@ -1277,7 +1277,8 @@ namespace bgfx { namespace d3d12 | BGFX_CAPS_TEXTURE_2D_ARRAY | BGFX_CAPS_TEXTURE_CUBE_ARRAY ); - g_caps.limits.maxTextureSize = 16384; + g_caps.limits.maxTextureSize = D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION; + g_caps.limits.maxTextureLayers = D3D12_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION; g_caps.limits.maxFBAttachments = uint8_t(bx::uint32_min(16, BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS) ); g_caps.limits.maxVertexStreams = BGFX_CONFIG_MAX_VERTEX_STREAMS; diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index bfc86d6d9..b1f2768f3 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -2316,7 +2316,8 @@ namespace bgfx { namespace gl : 0 ; - g_caps.limits.maxTextureSize = uint16_t(glGet(GL_MAX_TEXTURE_SIZE) ); + g_caps.limits.maxTextureSize = uint16_t(glGet(GL_MAX_TEXTURE_SIZE) ); + g_caps.limits.maxTextureLayers = uint16_t(bx::max(glGet(GL_MAX_ARRAY_TEXTURE_LAYERS), 1) ); if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) || BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES >= 30) diff --git a/src/renderer_gl.h b/src/renderer_gl.h index 529999750..eaaa076ba 100644 --- a/src/renderer_gl.h +++ b/src/renderer_gl.h @@ -525,6 +525,10 @@ typedef uint64_t GLuint64; # define GL_MAX_DRAW_BUFFERS 0x8824 #endif // GL_MAX_DRAW_BUFFERS +#ifndef GL_MAX_ARRAY_TEXTURE_LAYERS +# define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF +#endif // GL_MAX_ARRAY_TEXTURE_LAYERS + #ifndef GL_QUERY_RESULT # define GL_QUERY_RESULT 0x8866 #endif // GL_QUERY_RESULT diff --git a/src/renderer_noop.cpp b/src/renderer_noop.cpp index 7bf4c2d7e..cfbb08048 100644 --- a/src/renderer_noop.cpp +++ b/src/renderer_noop.cpp @@ -38,6 +38,35 @@ namespace bgfx { namespace noop | BGFX_CAPS_VERTEX_ATTRIB_HALF | BGFX_CAPS_VERTEX_ATTRIB_UINT10 ; + + // Pretend all features are available for all texture formats. + for (uint32_t formatIdx = 0; formatIdx < TextureFormat::Count; ++formatIdx) + { + g_caps.formats[formatIdx] = 0 + | BGFX_CAPS_FORMAT_TEXTURE_NONE + | BGFX_CAPS_FORMAT_TEXTURE_2D + | BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB + | BGFX_CAPS_FORMAT_TEXTURE_2D_EMULATED + | BGFX_CAPS_FORMAT_TEXTURE_3D + | BGFX_CAPS_FORMAT_TEXTURE_3D_SRGB + | BGFX_CAPS_FORMAT_TEXTURE_3D_EMULATED + | BGFX_CAPS_FORMAT_TEXTURE_CUBE + | BGFX_CAPS_FORMAT_TEXTURE_CUBE_SRGB + | BGFX_CAPS_FORMAT_TEXTURE_CUBE_EMULATED + | BGFX_CAPS_FORMAT_TEXTURE_VERTEX + | BGFX_CAPS_FORMAT_TEXTURE_IMAGE + | BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER + | BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER_MSAA + | BGFX_CAPS_FORMAT_TEXTURE_MSAA + | BGFX_CAPS_FORMAT_TEXTURE_MIP_AUTOGEN + ; + } + + // Pretend we have no limits + g_caps.limits.maxTextureSize = 16384; + g_caps.limits.maxTextureLayers = 2048; + g_caps.limits.maxFBAttachments = BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS; + g_caps.limits.maxVertexStreams = BGFX_CONFIG_MAX_VERTEX_STREAMS; } ~RendererContextNOOP()