shouldn't clear the m_AttachmentClearValues inDeviceContextGLImpl::NextSubpass
https://github.com/DiligentGraphics/DiligentCore/blob/8be34c5ac4021eec223cc4609e79fa71421063f8/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp#L658 call m_AttachmentClearValues.clear() in DeviceContextGLImpl::NextSubpass(),if there more than two subpass,the clear value not exists after first call for NextSubpass. delete this line work well.
Can you provide a render pass description that reproduces this issue?
Yes,It's a thee subpass render pass.
- the first subpass render primitives and generate gbuffers like 'COLOR_BUFFER,ENTITY_BUFFER,VELOCITY_BUFFER(MOTION)...'
- the second subpass is anti-aliasing pass
- the last pass for final image process and display.
draw code like this : `context->BeginRenderPass(attr); { DrawScenePass(); }
{ // call NextSubpass() will clear m_AttachmentClearValues in GL-Backend.https://github.com/DiligentGraphics/DiligentCore/blob/8be34c5ac4021eec223cc4609e79fa71421063f8/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp#L658 context->NextSubpass(); AAPass(); }
{ // in the last pass ,need clear the final render-target, // but m_AttachmentClearValues was cleared,so the program will crush at https://github.com/DiligentGraphics/DiligentCore/blob/8be34c5ac4021eec223cc4609e79fa71421063f8/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp#L502 context->NextSubpass(); FinalScreenPass(); }
context->EndRenderPass();`
DirectX and Vulkan backend no this issue ..
the attachments like this `{ attachments[COLOR_BUFFER].Format = rtv_fmts[COLOR_BUFFER]; attachments[COLOR_BUFFER].InitialState = RESOURCE_STATE::RESOURCE_STATE_RENDER_TARGET; attachments[COLOR_BUFFER].FinalState = RESOURCE_STATE::RESOURCE_STATE_INPUT_ATTACHMENT; attachments[COLOR_BUFFER].LoadOp = ATTACHMENT_LOAD_OP::ATTACHMENT_LOAD_OP_CLEAR; attachments[COLOR_BUFFER].StoreOp = ATTACHMENT_STORE_OP::ATTACHMENT_STORE_OP_DISCARD; }
{ /* * https://registry.khronos.org/webgl/specs/latest/2.0/#3.7.9 * webgl can't clear int */ attachments[ENTITY_BUFFER].Format = rtv_fmts[ENTITY_BUFFER]; attachments[ENTITY_BUFFER].InitialState = RESOURCE_STATE::RESOURCE_STATE_RENDER_TARGET; attachments[ENTITY_BUFFER].FinalState = RESOURCE_STATE::RESOURCE_STATE_SHADER_RESOURCE; attachments[ENTITY_BUFFER].LoadOp = ATTACHMENT_LOAD_OP::ATTACHMENT_LOAD_OP_CLEAR; attachments[ENTITY_BUFFER].StoreOp = ATTACHMENT_STORE_OP::ATTACHMENT_STORE_OP_STORE; }
{ attachments[VELOCITY_BUFFER].Format = rtv_fmts[VELOCITY_BUFFER]; attachments[VELOCITY_BUFFER].InitialState = RESOURCE_STATE::RESOURCE_STATE_RENDER_TARGET; attachments[VELOCITY_BUFFER].FinalState = RESOURCE_STATE::RESOURCE_STATE_INPUT_ATTACHMENT; attachments[VELOCITY_BUFFER].LoadOp = ATTACHMENT_LOAD_OP::ATTACHMENT_LOAD_OP_CLEAR; attachments[VELOCITY_BUFFER].StoreOp = ATTACHMENT_STORE_OP::ATTACHMENT_STORE_OP_STORE; }
{ attachments[DEPTH_STENCIL_BUFFER].Format = dsv_fmt; attachments[DEPTH_STENCIL_BUFFER].InitialState = RESOURCE_STATE::RESOURCE_STATE_DEPTH_WRITE; attachments[DEPTH_STENCIL_BUFFER].FinalState = RESOURCE_STATE::RESOURCE_STATE_INPUT_ATTACHMENT; attachments[DEPTH_STENCIL_BUFFER].LoadOp = ATTACHMENT_LOAD_OP::ATTACHMENT_LOAD_OP_CLEAR; attachments[DEPTH_STENCIL_BUFFER].StoreOp = ATTACHMENT_STORE_OP::ATTACHMENT_STORE_OP_STORE; }
{ attachments[PREV_COLOR_BUFFER].Format = rtv_fmts[COLOR_BUFFER]; attachments[PREV_COLOR_BUFFER].InitialState = RESOURCE_STATE::RESOURCE_STATE_INPUT_ATTACHMENT; attachments[PREV_COLOR_BUFFER].FinalState = RESOURCE_STATE::RESOURCE_STATE_INPUT_ATTACHMENT; attachments[PREV_COLOR_BUFFER].LoadOp = ATTACHMENT_LOAD_OP::ATTACHMENT_LOAD_OP_LOAD; attachments[PREV_COLOR_BUFFER].StoreOp = ATTACHMENT_STORE_OP::ATTACHMENT_STORE_OP_STORE; }
{ attachments[PREV_DEPTH_STENCIL_BUFFER].Format = dsv_fmt; attachments[PREV_DEPTH_STENCIL_BUFFER].InitialState = RESOURCE_STATE::RESOURCE_STATE_DEPTH_WRITE; attachments[PREV_DEPTH_STENCIL_BUFFER].FinalState = RESOURCE_STATE::RESOURCE_STATE_INPUT_ATTACHMENT; attachments[PREV_DEPTH_STENCIL_BUFFER].LoadOp = ATTACHMENT_LOAD_OP::ATTACHMENT_LOAD_OP_LOAD; attachments[PREV_DEPTH_STENCIL_BUFFER].StoreOp = ATTACHMENT_STORE_OP::ATTACHMENT_STORE_OP_STORE; }
{ attachments[AA_COLOR_BUFFER].Format = rtv_fmts[COLOR_BUFFER]; attachments[AA_COLOR_BUFFER].InitialState = RESOURCE_STATE::RESOURCE_STATE_RENDER_TARGET; attachments[AA_COLOR_BUFFER].FinalState = RESOURCE_STATE::RESOURCE_STATE_INPUT_ATTACHMENT; attachments[AA_COLOR_BUFFER].LoadOp = ATTACHMENT_LOAD_OP::ATTACHMENT_LOAD_OP_CLEAR; attachments[AA_COLOR_BUFFER].StoreOp = ATTACHMENT_STORE_OP::ATTACHMENT_STORE_OP_STORE; }
{ attachments[FINAL_COLOR_BUFFER].Format = _graphic_device->GetSwapChain()->GetDesc().ColorBufferFormat; attachments[FINAL_COLOR_BUFFER].InitialState = RESOURCE_STATE::RESOURCE_STATE_RENDER_TARGET; attachments[FINAL_COLOR_BUFFER].FinalState = RESOURCE_STATE::RESOURCE_STATE_SHADER_RESOURCE; attachments[FINAL_COLOR_BUFFER].LoadOp = ATTACHMENT_LOAD_OP::ATTACHMENT_LOAD_OP_CLEAR; attachments[FINAL_COLOR_BUFFER].StoreOp = ATTACHMENT_STORE_OP::ATTACHMENT_STORE_OP_STORE; }`