Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shouldn't clear the m_AttachmentClearValues inDeviceContextGLImpl::NextSubpass #497

Open
widefire opened this issue Jun 26, 2024 · 2 comments

Comments

@widefire
Copy link


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.

@TheMostDiligent
Copy link
Contributor

Can you provide a render pass description that reproduces this issue?

@widefire
Copy link
Author

Yes,It's a thee subpass render pass.

  1. the first subpass render primitives and generate gbuffers like 'COLOR_BUFFER,ENTITY_BUFFER,VELOCITY_BUFFER(MOTION)...'
  2. the second subpass is anti-aliasing pass
  3. 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.


context->NextSubpass();
AAPass();
}

{
// in the last pass ,need clear the final render-target,
// but m_AttachmentClearValues was cleared,so the program will crush at

ClearRenderTarget(pRTV, m_AttachmentClearValues[RTAttachmentRef.AttachmentIndex].Color, RESOURCE_STATE_TRANSITION_MODE_NONE);

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;
}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants