[Optimize] (Diligent/RenderPass): remove renderpass usage

This commit is contained in:
2025-07-06 10:21:15 +08:00
parent bf0c29b384
commit 9e3a5aefad
6 changed files with 303 additions and 302 deletions
@@ -26,7 +26,7 @@ namespace MG_Diligent {
MG_Global::unordered_map<GLuint, Diligent::IBuffer*> g_UniformBufferMap; MG_Global::unordered_map<GLuint, Diligent::IBuffer*> g_UniformBufferMap;
Diligent::IBuffer* g_TriangleFanIndexBuffer = nullptr; Diligent::IBuffer* g_TriangleFanIndexBuffer = nullptr;
GLuint g_NextResourceId = 0; GLuint g_NextResourceId = 0;
bool IsInRenderPass = false; // bool IsInRenderPass = false;
bool initialized = false; bool initialized = false;
void BuildInputLayout(GLuint program, VertexArrayState& vaState, void BuildInputLayout(GLuint program, VertexArrayState& vaState,
@@ -142,13 +142,13 @@ namespace MG_Diligent {
} }
hash_combine(hash, fbInfo.ColorRTVs.size()); hash_combine(hash, fbInfo.ColorRTVs.size());
if (!fbInfo.pRenderPass) { // if (!fbInfo.pRenderPass) {
for (const auto& rtv : fbInfo.ColorRTVs) { for (const auto& rtv : fbInfo.ColorRTVs) {
if (rtv) { if (rtv) {
hash_combine(hash, rtv->GetDesc().Format); hash_combine(hash, rtv->GetDesc().Format);
} }
} }
} // }
hash_combine(hash, fbInfo.DepthStencilFormat); hash_combine(hash, fbInfo.DepthStencilFormat);
auto& programObj = MG_State_T::programState->programs_[MG_State_T::programState->currentProgram_]; auto& programObj = MG_State_T::programState->programs_[MG_State_T::programState->currentProgram_];
@@ -198,17 +198,18 @@ namespace MG_Diligent {
PSOCreateInfo.GraphicsPipeline.InputLayout.LayoutElements = programInfo.inputLayout.data(); PSOCreateInfo.GraphicsPipeline.InputLayout.LayoutElements = programInfo.inputLayout.data();
PSOCreateInfo.GraphicsPipeline.InputLayout.NumElements = programInfo.inputLayout.size(); PSOCreateInfo.GraphicsPipeline.InputLayout.NumElements = programInfo.inputLayout.size();
if (fbInfo.pRenderPass) { // if (fbInfo.pRenderPass) {
PSOCreateInfo.GraphicsPipeline.pRenderPass = fbInfo.pRenderPass; // PSOCreateInfo.GraphicsPipeline.pRenderPass = fbInfo.pRenderPass;
} else { // } else {
PSOCreateInfo.GraphicsPipeline.pRenderPass = g_FramebufferMap[0].pRenderPass; // Default render pass // PSOCreateInfo.GraphicsPipeline.pRenderPass = g_FramebufferMap[0].pRenderPass; // Default render pass
} // }
PSOCreateInfo.GraphicsPipeline.PrimitiveTopology = GLPrimitiveTopologyToDiligent(primitiveTopology); PSOCreateInfo.GraphicsPipeline.PrimitiveTopology = GLPrimitiveTopologyToDiligent(primitiveTopology);
if (fbInfo.pRenderPass) { // if (fbInfo.pRenderPass) {
PSOCreateInfo.GraphicsPipeline.NumRenderTargets = 0; // PSOCreateInfo.GraphicsPipeline.NumRenderTargets = 0;
} else { // } else
{
PSOCreateInfo.GraphicsPipeline.NumRenderTargets = fbInfo.ColorRTVs.size(); PSOCreateInfo.GraphicsPipeline.NumRenderTargets = fbInfo.ColorRTVs.size();
if (PSOCreateInfo.GraphicsPipeline.NumRenderTargets == 0) { if (PSOCreateInfo.GraphicsPipeline.NumRenderTargets == 0) {
PSOCreateInfo.GraphicsPipeline.NumRenderTargets = 1; PSOCreateInfo.GraphicsPipeline.NumRenderTargets = 1;
@@ -225,7 +226,7 @@ namespace MG_Diligent {
} }
} }
PSOCreateInfo.GraphicsPipeline.DSVFormat = Diligent::TEX_FORMAT_UNKNOWN; PSOCreateInfo.GraphicsPipeline.DSVFormat = fbInfo.DepthStencilFormat;
Diligent::BlendStateDesc &blendDesc = PSOCreateInfo.GraphicsPipeline.BlendDesc; Diligent::BlendStateDesc &blendDesc = PSOCreateInfo.GraphicsPipeline.BlendDesc;
blendDesc.IndependentBlendEnable = false; blendDesc.IndependentBlendEnable = false;
@@ -245,7 +246,7 @@ namespace MG_Diligent {
(commonState.colorMask[3] ? Diligent::COLOR_MASK_ALPHA : 0)); (commonState.colorMask[3] ? Diligent::COLOR_MASK_ALPHA : 0));
MG_Util::Debug::LogD("Configured Blend State:"); MG_Util::Debug::LogD("Configured Blend State:");
MG_Util::Debug::LogD(" Using explicit render pass: %s", fbInfo.pRenderPass ? "true" : "false"); // MG_Util::Debug::LogD(" Using explicit render pass: %s", fbInfo.pRenderPass ? "true" : "false");
MG_Util::Debug::LogD(" NumRenderTargets: %u", PSOCreateInfo.GraphicsPipeline.NumRenderTargets); MG_Util::Debug::LogD(" NumRenderTargets: %u", PSOCreateInfo.GraphicsPipeline.NumRenderTargets);
MG_Util::Debug::LogD(" IndependentBlendEnable: %s", blendDesc.IndependentBlendEnable ? "true" : "false"); MG_Util::Debug::LogD(" IndependentBlendEnable: %s", blendDesc.IndependentBlendEnable ? "true" : "false");
MG_Util::Debug::LogD(" RenderTargets[0].BlendEnable: %s", blendDesc.RenderTargets[0].BlendEnable ? "true" : "false"); MG_Util::Debug::LogD(" RenderTargets[0].BlendEnable: %s", blendDesc.RenderTargets[0].BlendEnable ? "true" : "false");
@@ -804,13 +805,13 @@ namespace MG_EGL::Diligent {
RPDesc.SubpassCount = 1; RPDesc.SubpassCount = 1;
RPDesc.pSubpasses = Subpasses; RPDesc.pSubpasses = Subpasses;
MG_Util::Debug::LogD("Creating default render pass"); // MG_Util::Debug::LogD("Creating default render pass");
MG_Diligent::g_pDevice->CreateRenderPass(RPDesc, &MG_Diligent::g_FramebufferMap[0].pRenderPass); // MG_Diligent::g_pDevice->CreateRenderPass(RPDesc, &MG_Diligent::g_FramebufferMap[0].pRenderPass);
if (MG_Diligent::g_FramebufferMap[0].pRenderPass) { // if (MG_Diligent::g_FramebufferMap[0].pRenderPass) {
MG_Util::Debug::LogD("Default render pass created: %p", MG_Diligent::g_FramebufferMap[0].pRenderPass); // MG_Util::Debug::LogD("Default render pass created: %p", MG_Diligent::g_FramebufferMap[0].pRenderPass);
} else { // } else {
MG_Util::Debug::LogE("Failed to create default render pass"); // MG_Util::Debug::LogE("Failed to create default render pass");
} // }
} }
EGLSurface eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, NativeWindowType window, EGLSurface eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, NativeWindowType window,
@@ -896,34 +897,34 @@ namespace MG_EGL::Diligent {
EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface draw) { EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface draw) {
MG_Util::Debug::LogD("Flushing context"); MG_Util::Debug::LogD("Flushing context");
if (MG_Diligent::IsInRenderPass) { // if (MG_Diligent::IsInRenderPass) {
MG_Util::Debug::LogD("Ending current render pass."); // MG_Util::Debug::LogD("Ending current render pass.");
MG_Diligent::g_pContext->EndRenderPass(); // MG_Diligent::g_pContext->EndRenderPass();
MG_Diligent::IsInRenderPass = false; // MG_Diligent::IsInRenderPass = false;
MG_Util::Debug::LogD("Current render pass ended."); // MG_Util::Debug::LogD("Current render pass ended.");
} else { // } else {
MG_Util::Debug::LogD("No active render pass to end."); // MG_Util::Debug::LogD("No active render pass to end.");
} // }
MG_Diligent::g_pContext->Flush(); MG_Diligent::g_pContext->Flush();
MG_Util::Debug::LogD("Presenting swap chain"); MG_Util::Debug::LogD("Presenting swap chain");
MG_Diligent::g_pSwapChain->Present(); MG_Diligent::g_pSwapChain->Present();
MG_GL::GL::UpdateDefaultFramebuffer(); MG_GL::GL::UpdateDefaultFramebuffer();
if (MG_Diligent::IsInRenderPass) { // if (MG_Diligent::IsInRenderPass) {
MG_Util::Debug::LogD("Ending current render pass."); // MG_Util::Debug::LogD("Ending current render pass.");
MG_Diligent::g_pContext->EndRenderPass(); // MG_Diligent::g_pContext->EndRenderPass();
MG_Diligent::IsInRenderPass = false; // MG_Diligent::IsInRenderPass = false;
MG_Util::Debug::LogD("Current render pass ended."); // MG_Util::Debug::LogD("Current render pass ended.");
} else { // } else {
MG_Util::Debug::LogD("No active render pass to end."); // MG_Util::Debug::LogD("No active render pass to end.");
} // }
MG_Diligent::g_pContext->Flush(); MG_Diligent::g_pContext->Flush();
MG_Util::Debug::LogD("Finishing frame"); MG_Util::Debug::LogD("Finishing frame");
MG_Diligent::g_pContext->FinishFrame(); MG_Diligent::g_pContext->FinishFrame();
auto& fbInfo = MG_Diligent::g_FramebufferMap[0]; auto& fbInfo = MG_Diligent::g_FramebufferMap[0];
if (fbInfo.pRenderPass && fbInfo.pFramebuffer) { // if (/*fbInfo.pRenderPass &&*/ fbInfo.pFramebuffer) {
MG_Util::Debug::LogD("Setting render targets: %zu color attachments", fbInfo.ColorRTVs.size()); MG_Util::Debug::LogD("Setting render targets: %zu color attachments", fbInfo.ColorRTVs.size());
MG_Diligent::g_pContext->SetRenderTargets( MG_Diligent::g_pContext->SetRenderTargets(
static_cast<Uint32>(fbInfo.ColorRTVs.size()), static_cast<Uint32>(fbInfo.ColorRTVs.size()),
@@ -942,14 +943,14 @@ namespace MG_EGL::Diligent {
DefaultClearValues[1].DepthStencil.Depth = 1.0f; DefaultClearValues[1].DepthStencil.Depth = 1.0f;
DefaultClearValues[1].DepthStencil.Stencil = 0; DefaultClearValues[1].DepthStencil.Stencil = 0;
MG_Util::Debug::LogD("Beginning render pass: pass=%p, fb=%p", fbInfo.pRenderPass, fbInfo.pFramebuffer); // MG_Util::Debug::LogD("Beginning render pass: pass=%p, fb=%p", fbInfo.pRenderPass, fbInfo.pFramebuffer);
MG_Diligent::g_pContext->BeginRenderPass( // MG_Diligent::g_pContext->BeginRenderPass(
::Diligent::BeginRenderPassAttribs{ fbInfo.pRenderPass, fbInfo.pFramebuffer, // ::Diligent::BeginRenderPassAttribs{ fbInfo.pRenderPass, fbInfo.pFramebuffer,
2, DefaultClearValues, // 2, DefaultClearValues,
::Diligent::RESOURCE_STATE_TRANSITION_MODE_TRANSITION} // ::Diligent::RESOURCE_STATE_TRANSITION_MODE_TRANSITION}
); // );
MG_Diligent::IsInRenderPass = true; // MG_Diligent::IsInRenderPass = true;
} // }
// const auto& SCDesc = MG_Diligent::g_pSwapChain->GetDesc(); // const auto& SCDesc = MG_Diligent::g_pSwapChain->GetDesc();
// MG_Util::Debug::LogD("Setting viewport: width=%d, height=%d", SCDesc.Width, SCDesc.Height); // MG_Util::Debug::LogD("Setting viewport: width=%d, height=%d", SCDesc.Width, SCDesc.Height);
@@ -19,8 +19,8 @@ namespace MG_Diligent {
struct GLFramebufferInfo struct GLFramebufferInfo
{ {
Diligent::IFramebuffer* pFramebuffer = nullptr; // Diligent::IFramebuffer* pFramebuffer = nullptr;
Diligent::IRenderPass* pRenderPass = nullptr; // Diligent::IRenderPass* pRenderPass = nullptr;
std::vector<Diligent::ITextureView*> ColorRTVs; std::vector<Diligent::ITextureView*> ColorRTVs;
Diligent::ITextureView* pDepthStencilRTV = nullptr; Diligent::ITextureView* pDepthStencilRTV = nullptr;
Diligent::TEXTURE_FORMAT DepthStencilFormat = Diligent::TEX_FORMAT_UNKNOWN; Diligent::TEXTURE_FORMAT DepthStencilFormat = Diligent::TEX_FORMAT_UNKNOWN;
@@ -231,7 +231,7 @@ namespace MG_Diligent {
std::vector<Diligent::LayoutElement>& inputLayout); std::vector<Diligent::LayoutElement>& inputLayout);
extern bool initialized; extern bool initialized;
extern bool IsInRenderPass; // extern bool IsInRenderPass;
extern GLuint g_NextResourceId; extern GLuint g_NextResourceId;
} }
@@ -24,27 +24,27 @@ namespace MG_GL::GL {
MG_Diligent::GLFramebufferInfo& fbInfo = it->second; MG_Diligent::GLFramebufferInfo& fbInfo = it->second;
auto& commonState = *MG_State_T::commonState; auto& commonState = *MG_State_T::commonState;
if (MG_Diligent::IsInRenderPass) { // if (MG_Diligent::IsInRenderPass) {
MG_Util::Debug::LogD("Ending render pass before clear operation"); // MG_Util::Debug::LogD("Ending render pass before clear operation");
MG_Diligent::g_pContext->EndRenderPass(); // MG_Diligent::g_pContext->EndRenderPass();
MG_Diligent::IsInRenderPass = false; // MG_Diligent::IsInRenderPass = false;
} // }
MG_Util::Debug::LogD("Beginning render pass for clear operation"); // MG_Util::Debug::LogD("Beginning render pass for clear operation");
if (!fbInfo.pRenderPass) { // if (!fbInfo.pRenderPass) {
MG_GL::GL::CreateRenderPassAndFramebuffer(drawFramebuffer, // MG_GL::GL::CreateRenderPassAndFramebuffer(drawFramebuffer,
*MG_State_T::framebufferState->GetCurrentFBO(GL_DRAW_FRAMEBUFFER), fbInfo); // *MG_State_T::framebufferState->GetCurrentFBO(GL_DRAW_FRAMEBUFFER), fbInfo);
} // }
Diligent::BeginRenderPassAttribs beginAttribs; // Diligent::BeginRenderPassAttribs beginAttribs;
beginAttribs.pRenderPass = fbInfo.pRenderPass; // beginAttribs.pRenderPass = fbInfo.pRenderPass;
beginAttribs.pFramebuffer = fbInfo.pFramebuffer; // beginAttribs.pFramebuffer = fbInfo.pFramebuffer;
beginAttribs.StateTransitionMode = Diligent::RESOURCE_STATE_TRANSITION_MODE_TRANSITION; // beginAttribs.StateTransitionMode = Diligent::RESOURCE_STATE_TRANSITION_MODE_TRANSITION;
beginAttribs.ClearValueCount = 0; // beginAttribs.ClearValueCount = 0;
beginAttribs.pClearValues = nullptr; // beginAttribs.pClearValues = nullptr;
MG_Diligent::g_pContext->BeginRenderPass(beginAttribs); // MG_Diligent::g_pContext->BeginRenderPass(beginAttribs);
MG_Diligent::IsInRenderPass = true; // MG_Diligent::IsInRenderPass = true;
if (mask & GL_COLOR_BUFFER_BIT) { if (mask & GL_COLOR_BUFFER_BIT) {
for (size_t i = 0; i < fbInfo.ColorRTVs.size(); ++i) { for (size_t i = 0; i < fbInfo.ColorRTVs.size(); ++i) {
@@ -76,9 +76,9 @@ namespace MG_GL::GL {
} }
} }
MG_Util::Debug::LogD("Ending render pass after clear operation"); // MG_Util::Debug::LogD("Ending render pass after clear operation");
MG_Diligent::g_pContext->EndRenderPass(); // MG_Diligent::g_pContext->EndRenderPass();
MG_Diligent::IsInRenderPass = false; // MG_Diligent::IsInRenderPass = false;
} }
void Enable(GLenum cap) { void Enable(GLenum cap) {
@@ -5,9 +5,9 @@
#include "GL_Drawing.h" #include "GL_Drawing.h"
namespace MG_GL::GL { namespace MG_GL::GL {
void CreateRenderPassAndFramebuffer(GLuint framebuffer, // void CreateRenderPassAndFramebuffer(GLuint framebuffer,
const FramebufferObject& fbo, // const FramebufferObject& fbo,
MG_Diligent::GLFramebufferInfo& fbInfo); // MG_Diligent::GLFramebufferInfo& fbInfo);
bool IsSamplerType(GLenum type) { bool IsSamplerType(GLenum type) {
switch (type) { switch (type) {
@@ -357,59 +357,59 @@ namespace MG_GL::GL {
} }
} }
void EnsureRenderPassActive() { // void EnsureRenderPassActive() {
MG_Util::Debug::LogD("EnsureRenderPassActive called."); // MG_Util::Debug::LogD("EnsureRenderPassActive called.");
if (MG_Diligent::IsInRenderPass) { // if (MG_Diligent::IsInRenderPass) {
MG_Util::Debug::LogD("Render pass is already active."); // MG_Util::Debug::LogD("Render pass is already active.");
return; // return;
} // }
//
MG_Util::Debug::LogD("Render pass is not active, attempting to begin one."); // MG_Util::Debug::LogD("Render pass is not active, attempting to begin one.");
GLuint drawFB = MG_State_T::framebufferState->currentBindings_[GL_DRAW_FRAMEBUFFER]; // GLuint drawFB = MG_State_T::framebufferState->currentBindings_[GL_DRAW_FRAMEBUFFER];
if (drawFB == 0) { // if (drawFB == 0) {
MG_Util::Debug::LogD("drawFB is 0, using default framebuffer (0)."); // MG_Util::Debug::LogD("drawFB is 0, using default framebuffer (0).");
drawFB = 0; // drawFB = 0;
} // }
//
auto it = MG_Diligent::g_FramebufferMap.find(drawFB); // auto it = MG_Diligent::g_FramebufferMap.find(drawFB);
if (it == MG_Diligent::g_FramebufferMap.end()) { // if (it == MG_Diligent::g_FramebufferMap.end()) {
MG_Util::Debug::LogE("Framebuffer %u not found in g_FramebufferMap.", drawFB); // MG_Util::Debug::LogE("Framebuffer %u not found in g_FramebufferMap.", drawFB);
return; // return;
} // }
//
MG_Util::Debug::LogD("Found framebuffer %u in g_FramebufferMap.", drawFB); // MG_Util::Debug::LogD("Found framebuffer %u in g_FramebufferMap.", drawFB);
MG_Diligent::GLFramebufferInfo& fbInfo = it->second; // MG_Diligent::GLFramebufferInfo& fbInfo = it->second;
//
if (!fbInfo.pRenderPass || !fbInfo.pFramebuffer) { // if (!fbInfo.pRenderPass || !fbInfo.pFramebuffer) {
MG_Util::Debug::LogD("RenderPass or Framebuffer not yet created for FBO %u. Creating now.", drawFB); // MG_Util::Debug::LogD("RenderPass or Framebuffer not yet created for FBO %u. Creating now.", drawFB);
FramebufferObject* pFBO = MG_State_T::framebufferState->GetCurrentFBO(GL_DRAW_FRAMEBUFFER); // FramebufferObject* pFBO = MG_State_T::framebufferState->GetCurrentFBO(GL_DRAW_FRAMEBUFFER);
if (!pFBO) { // if (!pFBO) {
MG_Util::Debug::LogE("No current FBO found for GL_DRAW_FRAMEBUFFER when trying to create RenderPass/Framebuffer."); // MG_Util::Debug::LogE("No current FBO found for GL_DRAW_FRAMEBUFFER when trying to create RenderPass/Framebuffer.");
return; // return;
} // }
CreateRenderPassAndFramebuffer(drawFB, *pFBO, fbInfo); // CreateRenderPassAndFramebuffer(drawFB, *pFBO, fbInfo);
if (!fbInfo.pRenderPass || !fbInfo.pFramebuffer) { // if (!fbInfo.pRenderPass || !fbInfo.pFramebuffer) {
MG_Util::Debug::LogE("Failed to create RenderPass or Framebuffer for FBO %u.", drawFB); // MG_Util::Debug::LogE("Failed to create RenderPass or Framebuffer for FBO %u.", drawFB);
return; // return;
} // }
MG_Util::Debug::LogD("Successfully created RenderPass and Framebuffer for FBO %u.", drawFB); // MG_Util::Debug::LogD("Successfully created RenderPass and Framebuffer for FBO %u.", drawFB);
} // }
//
MG_Util::Debug::LogD("Proceeding to begin render pass for FBO %u.", drawFB); // MG_Util::Debug::LogD("Proceeding to begin render pass for FBO %u.", drawFB);
if (fbInfo.pRenderPass && fbInfo.pFramebuffer) { // if (fbInfo.pRenderPass && fbInfo.pFramebuffer) {
Diligent::BeginRenderPassAttribs beginRenderPassAttribs; // Diligent::BeginRenderPassAttribs beginRenderPassAttribs;
beginRenderPassAttribs.pFramebuffer = fbInfo.pFramebuffer; // beginRenderPassAttribs.pFramebuffer = fbInfo.pFramebuffer;
beginRenderPassAttribs.pRenderPass = fbInfo.pRenderPass; // beginRenderPassAttribs.pRenderPass = fbInfo.pRenderPass;
beginRenderPassAttribs.StateTransitionMode = Diligent::RESOURCE_STATE_TRANSITION_MODE_TRANSITION; // beginRenderPassAttribs.StateTransitionMode = Diligent::RESOURCE_STATE_TRANSITION_MODE_TRANSITION;
beginRenderPassAttribs.ClearValueCount = fbInfo.ClearValues.size(); // beginRenderPassAttribs.ClearValueCount = fbInfo.ClearValues.size();
beginRenderPassAttribs.pClearValues = fbInfo.ClearValues.data(); // beginRenderPassAttribs.pClearValues = fbInfo.ClearValues.data();
//
MG_Diligent::g_pContext->BeginRenderPass(beginRenderPassAttribs); // MG_Diligent::g_pContext->BeginRenderPass(beginRenderPassAttribs);
MG_Diligent::IsInRenderPass = true; // MG_Diligent::IsInRenderPass = true;
} else { // } else {
MG_Util::Debug::LogE("RenderPass or Framebuffer not yet created for FBO %u.", drawFB); // MG_Util::Debug::LogE("RenderPass or Framebuffer not yet created for FBO %u.", drawFB);
} // }
} // }
template<typename T> template<typename T>
void generate_triangle_fan_indices(std::vector<uint8_t>& out_data, const void* in_indices, size_t count) { void generate_triangle_fan_indices(std::vector<uint8_t>& out_data, const void* in_indices, size_t count) {
@@ -427,14 +427,14 @@ namespace MG_GL::GL {
} }
void PrepareForDraw(GLenum mode, GLsizei* pCount, GLenum type, const void*& pIndices) { void PrepareForDraw(GLenum mode, GLsizei* pCount, GLenum type, const void*& pIndices) {
if (MG_Diligent::IsInRenderPass) { // if (MG_Diligent::IsInRenderPass) {
MG_Util::Debug::LogD("Ending current render pass."); // MG_Util::Debug::LogD("Ending current render pass.");
MG_Diligent::g_pContext->EndRenderPass(); // MG_Diligent::g_pContext->EndRenderPass();
MG_Diligent::IsInRenderPass = false; // MG_Diligent::IsInRenderPass = false;
MG_Util::Debug::LogD("Current render pass ended."); // MG_Util::Debug::LogD("Current render pass ended.");
} else { // } else {
MG_Util::Debug::LogD("No active render pass to end."); // MG_Util::Debug::LogD("No active render pass to end.");
} // }
GLuint program = MG_State::GetCurrentProgram(); GLuint program = MG_State::GetCurrentProgram();
if (program == 0) { if (program == 0) {
@@ -728,10 +728,10 @@ namespace MG_GL::GL {
MG_Util::Debug::LogD(" FirstIndexLocation: %u", drawAttrs.FirstIndexLocation); MG_Util::Debug::LogD(" FirstIndexLocation: %u", drawAttrs.FirstIndexLocation);
MG_Util::Debug::LogD(" FirstInstanceLocation: %u", drawAttrs.FirstInstanceLocation); MG_Util::Debug::LogD(" FirstInstanceLocation: %u", drawAttrs.FirstInstanceLocation);
EnsureRenderPassActive(); // EnsureRenderPassActive();
MG_Diligent::g_pContext->DrawIndexed(drawAttrs); MG_Diligent::g_pContext->DrawIndexed(drawAttrs);
MG_Diligent::g_pContext->EndRenderPass(); // MG_Diligent::g_pContext->EndRenderPass();
MG_Diligent::IsInRenderPass = false; // MG_Diligent::IsInRenderPass = false;
MG_Util::Debug::LogD("DrawIndexed completed."); MG_Util::Debug::LogD("DrawIndexed completed.");
} }
@@ -769,10 +769,10 @@ namespace MG_GL::GL {
MG_Util::Debug::LogD(" FirstIndexLocation: %u", drawAttrs.FirstIndexLocation); MG_Util::Debug::LogD(" FirstIndexLocation: %u", drawAttrs.FirstIndexLocation);
MG_Util::Debug::LogD(" FirstInstanceLocation: %u", drawAttrs.FirstInstanceLocation); MG_Util::Debug::LogD(" FirstInstanceLocation: %u", drawAttrs.FirstInstanceLocation);
EnsureRenderPassActive(); // EnsureRenderPassActive();
MG_Diligent::g_pContext->DrawIndexed(drawAttrs); MG_Diligent::g_pContext->DrawIndexed(drawAttrs);
MG_Diligent::g_pContext->EndRenderPass(); // MG_Diligent::g_pContext->EndRenderPass();
MG_Diligent::IsInRenderPass = false; // MG_Diligent::IsInRenderPass = false;
MG_Util::Debug::LogD("DrawIndexed (BaseVertex) completed."); MG_Util::Debug::LogD("DrawIndexed (BaseVertex) completed.");
} }
@@ -998,10 +998,10 @@ namespace MG_GL::GL {
MG_Util::Debug::LogD(" BaseVertex: %d", item.BaseVertex); MG_Util::Debug::LogD(" BaseVertex: %d", item.BaseVertex);
} }
EnsureRenderPassActive(); // EnsureRenderPassActive();
MG_Diligent::g_pContext->MultiDrawIndexed(drawAttrs); MG_Diligent::g_pContext->MultiDrawIndexed(drawAttrs);
MG_Diligent::g_pContext->EndRenderPass(); // MG_Diligent::g_pContext->EndRenderPass();
MG_Diligent::IsInRenderPass = false; // MG_Diligent::IsInRenderPass = false;
MG_Util::Debug::LogD("MultiDrawIndexed completed."); MG_Util::Debug::LogD("MultiDrawIndexed completed.");
} }
@@ -6,15 +6,15 @@
namespace MG_GL::GL { namespace MG_GL::GL {
void ReleaseFramebufferResources(MG_Diligent::GLFramebufferInfo& fbInfo) { void ReleaseFramebufferResources(MG_Diligent::GLFramebufferInfo& fbInfo) {
if (fbInfo.pFramebuffer) { // if (fbInfo.pFramebuffer) {
fbInfo.pFramebuffer->Release(); // fbInfo.pFramebuffer->Release();
fbInfo.pFramebuffer = nullptr; // fbInfo.pFramebuffer = nullptr;
} // }
if (fbInfo.pRenderPass) { // if (fbInfo.pRenderPass) {
fbInfo.pRenderPass->Release(); // fbInfo.pRenderPass->Release();
fbInfo.pRenderPass = nullptr; // fbInfo.pRenderPass = nullptr;
} // }
} }
void CreateRenderPassAndFramebuffer(GLuint framebuffer, void CreateRenderPassAndFramebuffer(GLuint framebuffer,
@@ -52,115 +52,115 @@ namespace MG_GL::GL {
return; return;
} }
Diligent::RenderPassDesc RPDesc; // Diligent::RenderPassDesc RPDesc;
std::vector<Diligent::RenderPassAttachmentDesc> Attachments; // std::vector<Diligent::RenderPassAttachmentDesc> Attachments;
std::vector<Diligent::SubpassDesc> Subpasses; // std::vector<Diligent::SubpassDesc> Subpasses;
std::vector<Diligent::AttachmentReference> ColorRefs; // std::vector<Diligent::AttachmentReference> ColorRefs;
//
// for (size_t i = 0; i < fbInfo.ColorRTVs.size(); ++i) {
// if (fbInfo.ColorRTVs[i]) {
// Diligent::RenderPassAttachmentDesc ColorAttachment;
// ColorAttachment.Format = framebuffer != 0 ? fbInfo.ColorRTVs[i]->GetDesc().Format:
// MG_Diligent::g_pSwapChain->GetDesc().ColorBufferFormat;
// ColorAttachment.SampleCount = 1;
// ColorAttachment.InitialState = Diligent::RESOURCE_STATE_RENDER_TARGET;
// ColorAttachment.FinalState = Diligent::RESOURCE_STATE_RENDER_TARGET;
// ColorAttachment.LoadOp = Diligent::ATTACHMENT_LOAD_OP_LOAD;
// ColorAttachment.StoreOp = Diligent::ATTACHMENT_STORE_OP_STORE;
// Attachments.push_back(ColorAttachment);
//
// Diligent::AttachmentReference ColorRef;
// ColorRef.AttachmentIndex = static_cast<Diligent::Uint32>(Attachments.size() - 1);
// ColorRef.State = Diligent::RESOURCE_STATE_RENDER_TARGET;
// ColorRefs.push_back(ColorRef);
// MG_Util::Debug::LogD("CreateRenderPassAndFramebuffer: Added color attachment %zu", i);
// }
// }
for (size_t i = 0; i < fbInfo.ColorRTVs.size(); ++i) { // Diligent::AttachmentReference DepthRef;
if (fbInfo.ColorRTVs[i]) { // if (fbInfo.pDepthStencilRTV) {
Diligent::RenderPassAttachmentDesc ColorAttachment; // Diligent::RenderPassAttachmentDesc DepthAttachment;
ColorAttachment.Format = framebuffer != 0 ? fbInfo.ColorRTVs[i]->GetDesc().Format: // DepthAttachment.Format = fbInfo.DepthStencilFormat;
MG_Diligent::g_pSwapChain->GetDesc().ColorBufferFormat; // DepthAttachment.SampleCount = 1;
ColorAttachment.SampleCount = 1; // DepthAttachment.InitialState = Diligent::RESOURCE_STATE_DEPTH_WRITE;
ColorAttachment.InitialState = Diligent::RESOURCE_STATE_RENDER_TARGET; // DepthAttachment.FinalState = Diligent::RESOURCE_STATE_DEPTH_WRITE;
ColorAttachment.FinalState = Diligent::RESOURCE_STATE_RENDER_TARGET; // DepthAttachment.LoadOp = Diligent::ATTACHMENT_LOAD_OP_LOAD;
ColorAttachment.LoadOp = Diligent::ATTACHMENT_LOAD_OP_LOAD; // DepthAttachment.StoreOp = Diligent::ATTACHMENT_STORE_OP_STORE;
ColorAttachment.StoreOp = Diligent::ATTACHMENT_STORE_OP_STORE; // DepthAttachment.StencilLoadOp = Diligent::ATTACHMENT_LOAD_OP_LOAD;
Attachments.push_back(ColorAttachment); // DepthAttachment.StencilStoreOp = Diligent::ATTACHMENT_STORE_OP_STORE;
// Attachments.push_back(DepthAttachment);
//
// DepthRef.AttachmentIndex = static_cast<Diligent::Uint32>(Attachments.size() - 1);
// DepthRef.State = Diligent::RESOURCE_STATE_DEPTH_WRITE;
// MG_Util::Debug::LogD("CreateRenderPassAndFramebuffer: Added depth/stencil attachment");
// }
Diligent::AttachmentReference ColorRef; // Diligent::SubpassDesc Subpass;
ColorRef.AttachmentIndex = static_cast<Diligent::Uint32>(Attachments.size() - 1); // Subpass.RenderTargetAttachmentCount = static_cast<Diligent::Uint32>(ColorRefs.size());
ColorRef.State = Diligent::RESOURCE_STATE_RENDER_TARGET; // Subpass.pRenderTargetAttachments = ColorRefs.empty() ? nullptr : ColorRefs.data();
ColorRefs.push_back(ColorRef); // Subpass.pDepthStencilAttachment = fbInfo.pDepthStencilRTV ? &DepthRef : nullptr;
MG_Util::Debug::LogD("CreateRenderPassAndFramebuffer: Added color attachment %zu", i); // Subpasses.push_back(Subpass);
} //
} // RPDesc.AttachmentCount = static_cast<Diligent::Uint32>(Attachments.size());
// RPDesc.pAttachments = Attachments.empty() ? nullptr : Attachments.data();
// RPDesc.SubpassCount = static_cast<Diligent::Uint32>(Subpasses.size());
// RPDesc.pSubpasses = Subpasses.data();
//
// MG_Util::Debug::LogD("CreateRenderPassAndFramebuffer: Creating RenderPass with %u attachments and %u subpasses.",
// RPDesc.AttachmentCount, RPDesc.SubpassCount);
//
// MG_Diligent::g_pDevice->CreateRenderPass(RPDesc, &fbInfo.pRenderPass);
// if (!fbInfo.pRenderPass) {
// MG_Util::Debug::LogE("CreateRenderPassAndFramebuffer: Failed to create RenderPass.");
// return;
// }
// MG_Util::Debug::LogD("CreateRenderPassAndFramebuffer: RenderPass created successfully.");
Diligent::AttachmentReference DepthRef; // Diligent::FramebufferDesc FBDesc;
if (fbInfo.pDepthStencilRTV) { // FBDesc.Name = "Framebuffer";
Diligent::RenderPassAttachmentDesc DepthAttachment; //// FBDesc.pRenderPass = fbInfo.pRenderPass;
DepthAttachment.Format = fbInfo.DepthStencilFormat; // FBDesc.AttachmentCount = static_cast<Diligent::Uint32>(Attachments.size());
DepthAttachment.SampleCount = 1; //
DepthAttachment.InitialState = Diligent::RESOURCE_STATE_DEPTH_WRITE; // std::vector<Diligent::ITextureView *> FBAtachments(Attachments.size());
DepthAttachment.FinalState = Diligent::RESOURCE_STATE_DEPTH_WRITE; // for (size_t i = 0; i < ColorRefs.size(); ++i) {
DepthAttachment.LoadOp = Diligent::ATTACHMENT_LOAD_OP_LOAD; // if (i < fbInfo.ColorRTVs.size() && fbInfo.ColorRTVs[i]) {
DepthAttachment.StoreOp = Diligent::ATTACHMENT_STORE_OP_STORE; // FBAtachments[i] = fbInfo.ColorRTVs[i];
DepthAttachment.StencilLoadOp = Diligent::ATTACHMENT_LOAD_OP_LOAD; // }
DepthAttachment.StencilStoreOp = Diligent::ATTACHMENT_STORE_OP_STORE; // }
Attachments.push_back(DepthAttachment); //
// if (fbInfo.pDepthStencilRTV) {
// FBAtachments[ColorRefs.size()] = fbInfo.pDepthStencilRTV;
// }
DepthRef.AttachmentIndex = static_cast<Diligent::Uint32>(Attachments.size() - 1); // FBDesc.ppAttachments = FBAtachments.data();
DepthRef.State = Diligent::RESOURCE_STATE_DEPTH_WRITE; // FBDesc.Width = width;
MG_Util::Debug::LogD("CreateRenderPassAndFramebuffer: Added depth/stencil attachment"); // FBDesc.Height = height;
} // FBDesc.NumArraySlices = 1;
//
Diligent::SubpassDesc Subpass; // MG_Util::Debug::LogD("CreateRenderPassAndFramebuffer: FramebufferDesc Details:");
Subpass.RenderTargetAttachmentCount = static_cast<Diligent::Uint32>(ColorRefs.size()); // MG_Util::Debug::LogD(" Name: %s", FBDesc.Name ? FBDesc.Name : "N/A");
Subpass.pRenderTargetAttachments = ColorRefs.empty() ? nullptr : ColorRefs.data(); // MG_Util::Debug::LogD(" pRenderPass: %p", FBDesc.pRenderPass);
Subpass.pDepthStencilAttachment = fbInfo.pDepthStencilRTV ? &DepthRef : nullptr; // MG_Util::Debug::LogD(" AttachmentCount: %u", FBDesc.AttachmentCount);
Subpasses.push_back(Subpass); // for (Diligent::Uint32 i = 0; i < FBDesc.AttachmentCount; ++i) {
// if (FBDesc.ppAttachments && FBDesc.ppAttachments[i]) {
RPDesc.AttachmentCount = static_cast<Diligent::Uint32>(Attachments.size()); // Diligent::ITexture* pTexture = FBDesc.ppAttachments[i]->GetTexture();
RPDesc.pAttachments = Attachments.empty() ? nullptr : Attachments.data(); // if (pTexture) {
RPDesc.SubpassCount = static_cast<Diligent::Uint32>(Subpasses.size()); // const auto& texDesc = pTexture->GetDesc();
RPDesc.pSubpasses = Subpasses.data(); // MG_Util::Debug::LogD(" Attachment %u: Texture '%s', Dim: %ux%u",
// i, texDesc.Name ? texDesc.Name : "N/A", texDesc.Width, texDesc.Height);
MG_Util::Debug::LogD("CreateRenderPassAndFramebuffer: Creating RenderPass with %u attachments and %u subpasses.", // } else {
RPDesc.AttachmentCount, RPDesc.SubpassCount); // MG_Util::Debug::LogW(" Attachment %u: TextureView's texture is nullptr", i);
// }
MG_Diligent::g_pDevice->CreateRenderPass(RPDesc, &fbInfo.pRenderPass); // } else if (!FBDesc.ppAttachments) {
if (!fbInfo.pRenderPass) { // MG_Util::Debug::LogW(" FBDesc.ppAttachments is nullptr. Cannot access attachment %u.", i);
MG_Util::Debug::LogE("CreateRenderPassAndFramebuffer: Failed to create RenderPass."); // } else {
return; // MG_Util::Debug::LogD(" Attachment %u: nullptr", i);
} // }
MG_Util::Debug::LogD("CreateRenderPassAndFramebuffer: RenderPass created successfully."); // }
// MG_Util::Debug::LogD(" Width: %u", FBDesc.Width);
Diligent::FramebufferDesc FBDesc; // MG_Util::Debug::LogD(" Height: %u", FBDesc.Height);
FBDesc.Name = "Framebuffer"; // MG_Util::Debug::LogD(" NumArraySlices: %u", FBDesc.NumArraySlices);
FBDesc.pRenderPass = fbInfo.pRenderPass; // MG_Util::Debug::LogD(" fbInfo.pFramebuffer: %p", fbInfo.pFramebuffer);
FBDesc.AttachmentCount = static_cast<Diligent::Uint32>(Attachments.size());
std::vector<Diligent::ITextureView *> FBAtachments(Attachments.size());
for (size_t i = 0; i < ColorRefs.size(); ++i) {
if (i < fbInfo.ColorRTVs.size() && fbInfo.ColorRTVs[i]) {
FBAtachments[i] = fbInfo.ColorRTVs[i];
}
}
if (fbInfo.pDepthStencilRTV) {
FBAtachments[ColorRefs.size()] = fbInfo.pDepthStencilRTV;
}
FBDesc.ppAttachments = FBAtachments.data();
FBDesc.Width = width;
FBDesc.Height = height;
FBDesc.NumArraySlices = 1;
MG_Util::Debug::LogD("CreateRenderPassAndFramebuffer: FramebufferDesc Details:");
MG_Util::Debug::LogD(" Name: %s", FBDesc.Name ? FBDesc.Name : "N/A");
MG_Util::Debug::LogD(" pRenderPass: %p", FBDesc.pRenderPass);
MG_Util::Debug::LogD(" AttachmentCount: %u", FBDesc.AttachmentCount);
for (Diligent::Uint32 i = 0; i < FBDesc.AttachmentCount; ++i) {
if (FBDesc.ppAttachments && FBDesc.ppAttachments[i]) {
Diligent::ITexture* pTexture = FBDesc.ppAttachments[i]->GetTexture();
if (pTexture) {
const auto& texDesc = pTexture->GetDesc();
MG_Util::Debug::LogD(" Attachment %u: Texture '%s', Dim: %ux%u",
i, texDesc.Name ? texDesc.Name : "N/A", texDesc.Width, texDesc.Height);
} else {
MG_Util::Debug::LogW(" Attachment %u: TextureView's texture is nullptr", i);
}
} else if (!FBDesc.ppAttachments) {
MG_Util::Debug::LogW(" FBDesc.ppAttachments is nullptr. Cannot access attachment %u.", i);
} else {
MG_Util::Debug::LogD(" Attachment %u: nullptr", i);
}
}
MG_Util::Debug::LogD(" Width: %u", FBDesc.Width);
MG_Util::Debug::LogD(" Height: %u", FBDesc.Height);
MG_Util::Debug::LogD(" NumArraySlices: %u", FBDesc.NumArraySlices);
MG_Util::Debug::LogD(" fbInfo.pFramebuffer: %p", fbInfo.pFramebuffer);
fbInfo.ClearValues.clear(); fbInfo.ClearValues.clear();
for (size_t i = 0; i < fbInfo.ColorRTVs.size(); ++i) { for (size_t i = 0; i < fbInfo.ColorRTVs.size(); ++i) {
@@ -179,12 +179,12 @@ namespace MG_GL::GL {
fbInfo.ClearValues.push_back(clearValue); fbInfo.ClearValues.push_back(clearValue);
} }
MG_Diligent::g_pDevice->CreateFramebuffer(FBDesc, &fbInfo.pFramebuffer); // MG_Diligent::g_pDevice->CreateFramebuffer(FBDesc, &fbInfo.pFramebuffer);
if (!fbInfo.pFramebuffer) { // if (!fbInfo.pFramebuffer) {
MG_Util::Debug::LogE("CreateRenderPassAndFramebuffer: Failed to create Framebuffer."); // MG_Util::Debug::LogE("CreateRenderPassAndFramebuffer: Failed to create Framebuffer.");
return; // return;
} // }
MG_Util::Debug::LogD("CreateRenderPassAndFramebuffer: Framebuffer created successfully."); // MG_Util::Debug::LogD("CreateRenderPassAndFramebuffer: Framebuffer created successfully.");
} }
void UpdateDefaultFramebuffer() { void UpdateDefaultFramebuffer() {
@@ -249,13 +249,13 @@ namespace MG_GL::GL {
if (it != MG_Diligent::g_FramebufferMap.end()) { if (it != MG_Diligent::g_FramebufferMap.end()) {
MG_Diligent::GLFramebufferInfo& fbInfo = it->second; MG_Diligent::GLFramebufferInfo& fbInfo = it->second;
if (fbInfo.pFramebuffer) { // if (fbInfo.pFramebuffer) {
fbInfo.pFramebuffer->Release(); // fbInfo.pFramebuffer->Release();
} // }
if (fbInfo.pRenderPass) { // if (fbInfo.pRenderPass) {
fbInfo.pRenderPass->Release(); // fbInfo.pRenderPass->Release();
} // }
for (auto& rtv : fbInfo.ColorRTVs) { for (auto& rtv : fbInfo.ColorRTVs) {
if (rtv) rtv->Release(); if (rtv) rtv->Release();
@@ -279,14 +279,14 @@ namespace MG_GL::GL {
if (result == GL_NO_ERROR) { if (result == GL_NO_ERROR) {
MG_Util::Debug::LogD("BindFramebuffer: MG_State::BindFramebuffer successful."); MG_Util::Debug::LogD("BindFramebuffer: MG_State::BindFramebuffer successful.");
if (MG_Diligent::IsInRenderPass) { // if (MG_Diligent::IsInRenderPass) {
MG_Util::Debug::LogD("BindFramebuffer: Ending current render pass."); // MG_Util::Debug::LogD("BindFramebuffer: Ending current render pass.");
MG_Diligent::g_pContext->EndRenderPass(); // MG_Diligent::g_pContext->EndRenderPass();
MG_Diligent::IsInRenderPass = false; // MG_Diligent::IsInRenderPass = false;
MG_Util::Debug::LogD("BindFramebuffer: Current render pass ended."); // MG_Util::Debug::LogD("BindFramebuffer: Current render pass ended.");
} else { // } else {
MG_Util::Debug::LogD("BindFramebuffer: No active render pass to end."); // MG_Util::Debug::LogD("BindFramebuffer: No active render pass to end.");
} // }
if (framebuffer == 0) { if (framebuffer == 0) {
@@ -309,13 +309,13 @@ namespace MG_GL::GL {
MG_Diligent::GLFramebufferInfo& fbInfo = it->second; MG_Diligent::GLFramebufferInfo& fbInfo = it->second;
if (!fbInfo.pRenderPass || !fbInfo.pFramebuffer) { // if (/*!fbInfo.pRenderPass || */!fbInfo.pFramebuffer) {
MG_Util::Debug::LogD("BindFramebuffer: RenderPass or Framebuffer not yet created for framebuffer %u. Creating now.", framebuffer); // MG_Util::Debug::LogD("BindFramebuffer: RenderPass or Framebuffer not yet created for framebuffer %u. Creating now.", framebuffer);
CreateRenderPassAndFramebuffer(framebuffer, pFBO ? *pFBO : FramebufferObject(), fbInfo); // CreateRenderPassAndFramebuffer(framebuffer, pFBO ? *pFBO : FramebufferObject(), fbInfo);
MG_Util::Debug::LogD("BindFramebuffer: RenderPass and Framebuffer creation attempted for framebuffer %u.", framebuffer); // MG_Util::Debug::LogD("BindFramebuffer: RenderPass and Framebuffer creation attempted for framebuffer %u.", framebuffer);
} else { // } else {
MG_Util::Debug::LogD("BindFramebuffer: RenderPass and Framebuffer already exist for framebuffer %u.", framebuffer); // MG_Util::Debug::LogD("BindFramebuffer: RenderPass and Framebuffer already exist for framebuffer %u.", framebuffer);
} // }
MG_Util::Debug::LogD("BindFramebuffer: Setting render targets. ColorRTVs count: %zu, DepthStencilRTV: %p", MG_Util::Debug::LogD("BindFramebuffer: Setting render targets. ColorRTVs count: %zu, DepthStencilRTV: %p",
fbInfo.ColorRTVs.size(), fbInfo.pDepthStencilRTV); fbInfo.ColorRTVs.size(), fbInfo.pDepthStencilRTV);
@@ -342,16 +342,16 @@ namespace MG_GL::GL {
MG_Diligent::GLFramebufferInfo& fbInfo = it->second; MG_Diligent::GLFramebufferInfo& fbInfo = it->second;
if (fbInfo.pFramebuffer) { // if (fbInfo.pFramebuffer) {
fbInfo.pFramebuffer->Release(); // fbInfo.pFramebuffer->Release();
fbInfo.pFramebuffer = nullptr; // fbInfo.pFramebuffer = nullptr;
MG_Util::Debug::LogD("Released existing framebuffer"); // MG_Util::Debug::LogD("Released existing framebuffer");
} // }
if (fbInfo.pRenderPass) { // if (fbInfo.pRenderPass) {
fbInfo.pRenderPass->Release(); // fbInfo.pRenderPass->Release();
fbInfo.pRenderPass = nullptr; // fbInfo.pRenderPass = nullptr;
MG_Util::Debug::LogD("Released existing render pass"); // MG_Util::Debug::LogD("Released existing render pass");
} // }
if (texture == 0) { if (texture == 0) {
MG_Util::Debug::LogD("Unbinding attachment: %s", MG_Util::Debug::GLEnumToString(attachment)); MG_Util::Debug::LogD("Unbinding attachment: %s", MG_Util::Debug::GLEnumToString(attachment));
@@ -515,12 +515,12 @@ namespace MG_GL::GL {
void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) { GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) {
if (MG_Diligent::IsInRenderPass) { // if (MG_Diligent::IsInRenderPass) {
MG_Util::Debug::LogD("Ending current render pass."); // MG_Util::Debug::LogD("Ending current render pass.");
MG_Diligent::g_pContext->EndRenderPass(); // MG_Diligent::g_pContext->EndRenderPass();
MG_Diligent::IsInRenderPass = false; // MG_Diligent::IsInRenderPass = false;
MG_Util::Debug::LogD("Current render pass ended."); // MG_Util::Debug::LogD("Current render pass ended.");
} // }
GLuint readFB = MG_State_T::framebufferState->currentBindings_[GL_READ_FRAMEBUFFER]; GLuint readFB = MG_State_T::framebufferState->currentBindings_[GL_READ_FRAMEBUFFER];
GLuint drawFB = MG_State_T::framebufferState->currentBindings_[GL_DRAW_FRAMEBUFFER]; GLuint drawFB = MG_State_T::framebufferState->currentBindings_[GL_DRAW_FRAMEBUFFER];
@@ -648,10 +648,10 @@ namespace MG_GL::GL {
MG_Util::Debug::LogD("TexSubImage2D: Updating region [%d,%d]-[%d,%d] at level %d, %d bytes", MG_Util::Debug::LogD("TexSubImage2D: Updating region [%d,%d]-[%d,%d] at level %d, %d bytes",
xoffset, yoffset, xoffset+width, yoffset+height, level, width * height * GetBytesPerPixel(format, type)); xoffset, yoffset, xoffset+width, yoffset+height, level, width * height * GetBytesPerPixel(format, type));
if (MG_Diligent::IsInRenderPass) { // if (MG_Diligent::IsInRenderPass) {
MG_Diligent::g_pContext->EndRenderPass(); // MG_Diligent::g_pContext->EndRenderPass();
MG_Diligent::IsInRenderPass = false; // MG_Diligent::IsInRenderPass = false;
} // }
MG_Diligent::g_pContext->UpdateTexture( MG_Diligent::g_pContext->UpdateTexture(
pTexture, pTexture,