[Feat] (Diligent, EGL): forward eglSwapInterval to swap chain Present

- Renderer stores the requested swap interval and passes it to ISwapChain::Present
- SetSwapInterval now updates the active renderer instead of being a no-op
This commit is contained in:
BZLZHH
2026-08-23 11:01:40 +08:00
parent b43ec25bd7
commit e418063b08
4 changed files with 12 additions and 4 deletions
+1 -1
View File
@@ -220,7 +220,7 @@ Notes:
- User framebuffers now support texture color attachments, renderbuffer color readback, multiple simultaneous color targets, and depth/stencil texture or renderbuffer attachments.
- Textures auto-sync `ITextureObject` → Diligent resources, including mip levels and sampler state; compressed textures and integer/3-channel formats that Diligent lacks are still skipped.
- Global UBO (default-block `glUniform*`) and named application UBO blocks (through `glBindBufferBase`/`glUniformBlockBinding`) now upload and bind; SSBOs are still not fed from frontend buffer bindings.
- Swapchain creation and resize are wired for native EGL window surfaces via `Diligent::ISwapChain`; `Present()` presents the active swap chain when present and otherwise flushes the offscreen target. Actual on-screen EGL presentation is still untested in this headless environment, and the X11 display/connection fields are not yet plumbed through `WindowHandle`. `SetSwapInterval` remains a no-op.
- Swapchain creation and resize are wired for native EGL window surfaces via `Diligent::ISwapChain`; `Present()` presents the active swap chain when present and otherwise flushes the offscreen target. Actual on-screen EGL presentation is still untested in this headless environment, and the X11 display/connection fields are not yet plumbed through `WindowHandle`. `SetSwapInterval` now forwards the requested sync interval to `ISwapChain::Present()`.
- No transform feedback / GPU-accelerated queries / non-color readback; fence sync and timer queries use CPU fallbacks.
- Draw range, multi-draw, instanced-draw wrappers, clear-buffer, blit, read-pixels, CopyTexImage*, CopyImageSubData, GenerateMipmap, GetTexImage/GetTextureImage and indirect draws are now wired; buffer subdata paths still remain.
- A last-PSO cache now avoids recreating the pipeline when program/render-state/topology/VAO layout is unchanged; texture/UBO resources are still rebound dynamically per draw.
@@ -659,8 +659,10 @@ namespace MobileGL::MG_Backend::DiligentBackend {
}
void SetSwapInterval(Int interval) {
// No native swapchain yet; the offscreen renderer ignores the interval.
(void)interval;
auto* renderer = GetActiveRenderer();
if (renderer != nullptr) {
renderer->SetSwapInterval(interval > 0 ? static_cast<Uint32>(interval) : 0);
}
}
void Present() {
@@ -2040,13 +2040,17 @@ void main()
return true;
}
void DiligentRenderer::SetSwapInterval(Uint32 interval) {
m_swapInterval = interval;
}
void DiligentRenderer::ReleaseSwapChain() {
m_pSwapChain.Release();
}
void DiligentRenderer::Present() {
if (m_pSwapChain) {
m_pSwapChain->Present(0);
m_pSwapChain->Present(m_swapInterval);
} else if (m_pContext) {
// Offscreen renderer: nothing to present yet.
m_pContext->Flush();
@@ -65,6 +65,7 @@ namespace MobileGL::MG_Backend::DiligentBackend {
Bool CreateSwapChain(::Diligent::IEngineFactoryVk* factory, const WindowHandle& handle,
Uint32 width, Uint32 height);
Bool ResizeSwapChain(Uint32 width, Uint32 height);
void SetSwapInterval(Uint32 interval);
// Creates a simple 2D RGBA8 texture from CPU data and makes it available
// to state PSOs under the shader variable name "g_Texture".
Bool CreateTestTexture(const void* data, Uint32 width, Uint32 height);
@@ -143,6 +144,7 @@ namespace MobileGL::MG_Backend::DiligentBackend {
UnorderedMap<Uint64, ::Diligent::RefCntAutoPtr<::Diligent::IBuffer>> m_namedUboCache;
Uint32 m_width = 256;
Uint32 m_height = 256;
Uint32 m_swapInterval = 0;
Uint32 m_lastDrawVertexCount = 0;
Uint64 m_lastPSOKey = 0;
Bool m_hasCachedPSO = false;