mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-07 19:58:32 +09:00
[Feat] (Diligent, MG_Impl): wire GenerateMipmap via Diligent GPU mip generation
- Create state textures with MISC_TEXTURE_FLAG_GENERATE_MIPS - GenerateMipmap resolves active GL_TEXTURE_2D and calls IDeviceContext::GenerateMips - Update handoff; 16 Diligent tests pass
This commit is contained in:
+2
-1
@@ -158,6 +158,7 @@ Verified locally on Turnip Adreno 750:
|
||||
- `BlitFramebuffer` (same-size color copy between current read/draw FBOs)
|
||||
- `CopyTexImage2D` / `CopyTexSubImage2D` (whole-color copy fallback)
|
||||
- `CopyImageSubData` (whole-texture copy between two texture objects)
|
||||
- `GenerateMipmap` (Diligent GPU mip generation on state textures)
|
||||
- `GetTexImage` / `GetTextureImage` (RGBA8 readback)
|
||||
- `ReadPixels` from default and user color attachments
|
||||
- Primitive expansion:
|
||||
@@ -218,7 +219,7 @@ Notes:
|
||||
- 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.
|
||||
- No swapchain / EGL window surface presentation yet; `Present()` only flushes.
|
||||
- No transform feedback / queries / sync / readback of non-color resources.
|
||||
- Draw range, multi-draw, instanced-draw wrappers, clear-buffer, blit, read-pixels, CopyTexImage*, GetTexImage/GetTextureImage and indirect draws are now wired; buffer subdata paths still remain.
|
||||
- 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.
|
||||
- The `GLFunctionsTable` is only partially populated.
|
||||
|
||||
|
||||
@@ -539,6 +539,18 @@ namespace MobileGL::MG_Backend::DiligentBackend {
|
||||
}
|
||||
}
|
||||
|
||||
void GenerateMipmap(GLenum target) {
|
||||
auto* renderer = GetActiveRenderer();
|
||||
if (renderer == nullptr || MG_State::pGLContext == nullptr || target != GL_TEXTURE_2D) {
|
||||
return;
|
||||
}
|
||||
auto& unit = MG_State::pGLContext->GetTextureUnitObject(MG_State::pGLContext->GetActiveTextureUnit());
|
||||
auto texture = unit.GetBindingSlot(TextureTarget::Texture2D).GetBoundObject();
|
||||
if (texture) {
|
||||
renderer->GenerateMipmap(*texture);
|
||||
}
|
||||
}
|
||||
|
||||
void Present() {
|
||||
auto* renderer = GetActiveRenderer();
|
||||
if (renderer != nullptr) {
|
||||
@@ -653,6 +665,7 @@ namespace MobileGL::MG_Backend::DiligentBackend {
|
||||
m_functions.GL.CopyTexImage2D = CopyTexImage2D;
|
||||
m_functions.GL.CopyTexSubImage2D = CopyTexSubImage2D;
|
||||
m_functions.GL.CopyImageSubData = CopyImageSubData;
|
||||
m_functions.GL.GenerateMipmap = GenerateMipmap;
|
||||
m_functions.GL.GetTexImage = GetTexImage;
|
||||
m_functions.GL.GetTextureImage = GetTextureImage;
|
||||
m_functions.GL.ReadPixels = ReadPixels;
|
||||
|
||||
@@ -714,6 +714,7 @@ void main()
|
||||
} else {
|
||||
texDesc.BindFlags |= ::Diligent::BIND_RENDER_TARGET;
|
||||
}
|
||||
texDesc.MiscFlags = ::Diligent::MISC_TEXTURE_FLAG_GENERATE_MIPS;
|
||||
|
||||
::Diligent::RefCntAutoPtr<::Diligent::ITexture> pTexture;
|
||||
m_pDevice->CreateTexture(texDesc, nullptr, &pTexture);
|
||||
@@ -1839,6 +1840,17 @@ void main()
|
||||
m_pContext->CopyTexture(copyAttribs);
|
||||
}
|
||||
|
||||
void DiligentRenderer::GenerateMipmap(MG_State::GLState::ITextureObject& texture) {
|
||||
if (m_pContext == nullptr || SyncTexture(texture) == nullptr) {
|
||||
return;
|
||||
}
|
||||
auto it = m_textureCache.find(texture.GetLifetimeId());
|
||||
if (it == m_textureCache.end() || !it->second.SRV) {
|
||||
return;
|
||||
}
|
||||
m_pContext->GenerateMips(it->second.SRV);
|
||||
}
|
||||
|
||||
Bool DiligentRenderer::ReadTextureImage(MG_State::GLState::ITextureObject& texture, Uint32 level,
|
||||
void* pixels) {
|
||||
if (!m_initialized || !m_pContext || pixels == nullptr) {
|
||||
|
||||
@@ -67,6 +67,7 @@ namespace MobileGL::MG_Backend::DiligentBackend {
|
||||
GLbitfield mask, GLenum filter);
|
||||
void CopyReadFramebufferToTexture(MG_State::GLState::ITextureObject& dst);
|
||||
void CopyTextureSubData(MG_State::GLState::ITextureObject& src, MG_State::GLState::ITextureObject& dst);
|
||||
void GenerateMipmap(MG_State::GLState::ITextureObject& texture);
|
||||
Bool ReadTextureImage(MG_State::GLState::ITextureObject& texture, Uint32 level, void* pixels);
|
||||
void Present();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user