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

Add support for Extended Dynamic State 3 #3071

Merged

Conversation

stephen-bjore
Copy link

@stephen-bjore stephen-bjore commented Sep 25, 2023

Description

Add support for Extended Dynamic State 3.

Copy link
Owner

@baldurk baldurk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this, this looks good overall. I've made a few notes that shouldn't be too complex to sort through.

renderdoc/driver/vulkan/vk_common.h Outdated Show resolved Hide resolved
renderdoc/driver/vulkan/vk_core.h Show resolved Hide resolved
renderdoc/driver/vulkan/vk_replay.cpp Show resolved Hide resolved

ret.colorBlend.blends.resize(p.attachments.size());
for(size_t i = 0; i < p.attachments.size(); i++)
{
ret.colorBlend.blends[i].enabled = p.attachments[i].blendEnable;
if(i < state.colorBlendEnable.size())
ret.colorBlend.blends[i].enabled = state.colorBlendEnable[i] != VK_FALSE;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the earlier comment, this should reset the values to a default (in this case false, similar for other values) if it's not specified.

I also had to check the VUs and I'm not 100% sure - can you clarify what the behaviour should be regarding these counts matching? In most cases for vulkan the counts are required to match when specified in multiple different places, but the VU for this one seems to say you only need to specify a value for "active color attachments". Does that mean if there are attachments which are unused this check may be necessary and it would be valid for the application to have only specified some smaller number of values in these color blend arrays?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes here now worry me - as they do the opposite from what they did before by assuming that the arrays are all matching in size. I couldn't find any VU actually requiring that which is why I was looking for clarification in the comment above.

Checking again, I can also see this:

attachmentCount is the number of VkPipelineColorBlendAttachmentState elements in pAttachments. It is ignored if the pipeline is created with VK_DYNAMIC_STATE_COLOR_BLEND_ENABLE_EXT, VK_DYNAMIC_STATE_COLOR_BLEND_EQUATION_EXT, and VK_DYNAMIC_STATE_COLOR_WRITE_MASK_EXT dynamic states set, and either VK_DYNAMIC_STATE_COLOR_BLEND_ADVANCED_EXT set or advancedBlendCoherentOperations is not enabled on the device.

Which seems like it's possible that p.attachments could be entirely empty even though the pipeline does have attachments which it expects to write to (and possibly blend to) depending on dynamic state.

This definitely needs a solid understanding of where these counts are intended to match and where they can be different, as it is right now this doesn't look correct to me.

renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp Outdated Show resolved Hide resolved
renderdoc/driver/vulkan/wrappers/vk_dynamic_funcs.cpp Outdated Show resolved Hide resolved
renderdoc/driver/vulkan/wrappers/vk_dynamic_funcs.cpp Outdated Show resolved Hide resolved
@stephen-bjore
Copy link
Author

Updated the branch based on the comments above. Please let us know if you have additional comments, or would like responses to any of the previous comments.

@baldurk
Copy link
Owner

baldurk commented Oct 2, 2023

There's one outstanding issue that I think needs to be resolved - what happens with matching counts for dynamic arrays of state.

@stephen-bjore stephen-bjore force-pushed the extended-dynamic-state-3-support branch 2 times, most recently from 81e7f15 to 289d586 Compare October 11, 2023 21:19
@stephen-bjore
Copy link
Author

Updated again based on previous comments and conversations. As always, feedback is appreciated!

for(size_t i = 0; i < p.attachments.size(); i++)
// find size if no static pipeline state
size_t numAttach = std::max({state.colorBlendEnable.size(), state.colorBlendEquation.size(),
state.colorWriteEnable.size(), state.colorWriteMask.size()});
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something I appreciate might feel nitpicky, generally I avoid std:: where possible. This std::max overload might be supported as the docs seem to suggest it's C++11, but I would bet good money that Android will probably ruin that somehow as it always does - I don't know if the Android compilers we target fully support C++11 as I've had problems with that in the past.

I'd rather you use RDCMAX here and do it one by one for each value.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been changed in the latest update.

Copy link
Owner

@baldurk baldurk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks good now, I've noted one minor code-style thing with the latest changes but then it should be ready to merge.

@stephen-bjore stephen-bjore force-pushed the extended-dynamic-state-3-support branch from 289d586 to d9f7053 Compare October 12, 2023 00:03
@baldurk baldurk merged commit de89811 into baldurk:v1.x Oct 12, 2023
16 checks passed
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

Successfully merging this pull request may close these issues.

3 participants