Repository navigation
Fix color mask display when color write enable is static - #3929
Conversation
baldurk
left a comment
There was a problem hiding this comment.
If I understand this fix correctly then Serialise_vkCmdSetColorWriteMaskEXT should also fill out renderstate.colorWriteEnable - I think it should set it all to true since that just means the mask gets used. The idea of this state tracking code is that when a pipeline is bound we set all of its static state into the renderstate, and any dynamic state gets skipped - the application is responsible for setting all dynamic states before or after the pipeline bind, so it effectively layers and the state comes from exactly one source depending on if it's static or dynamic.
If we don't do that then nothing sets renderstate.colorWriteEnable when either of these are dynamic, so it may become stale. I expect in practice no-one will ever make a pipeline with color write enable state as static because it's pretty meaningless and only exists to define the dynamic state, but if you had a pipeline where color write enable was dynamic and you set it some of them to false, then bound a pipeline where color write mask was dynamic, nothing would reset that color write enable state now after your change so it would incorrectly be reported as disabled.
|
Ah I was debating something along those lines with myself. I understand your point about single source of truth, that's how I implemented dynamic state in a driver myself, so no argument there. Setting
If my understanding of the first two cases is correct, then what I can do here is to unconditionally set write-enable to true in this same piece of code. The internal debate I had was whether it makes any difference if the array is empty or set to all true values. I thought empty would be fine (since elsewhere empty implies enabled writes), but as you pointed out it doesn't stay empty after pipeline changes. I'll update the PR in a few hours. Do let me know if my assumption is incorrect (my assumption being that "color mask 0 + color write enabled" behaves identically to "color mask 0 + color write disabled"). |
b653b81 to
e8d0afa
Compare
|
Actually found a minute to update the PR, please take a look again. My reasoning for why this is ok is that if both state is dynamic, the app could set color-write-enable to true and color-write-mask to false and that's presumably fine. If color-write-enable is not dynamic, it's as if it's set to true and works the same way. |
The thing is that this is not quite accurate, though as I say in practical terms I don't expect anyone to use the state statically because why would you bother. We do need to handle what the spec defines though. The spec defines that there is As I understand it, this is mostly just a quirk of how the spec was written so that the dynamic state can be defined in terms of "setting that state dynamically" and that's where I don't think your updated code is quite correct in handling this specific case, but I think you're right that setting writeEnable in I think in order to handle this properly we need to track write enable entirely separately from what the pipeline's static writeMask was so that this static state can be applied entirely independently of what the writeMask was. Flattening it down means we can't distinguish and can't properly apply them depending on the combination of dynamic states. |
e8d0afa to
d89f428
Compare
When the color write enable state (from VK_EXT_color_write_enable) is not dynamic (i.e the extension is not used), VulkanRenderState::colorWriteEnable was initialized from pipeline's color mask info. However, this information should be ignored if color write mask is dynamic (with shader object / EDS3). Instead, if color write enable state is not dynamic, it can be implicitly considered to be true if VkPipelineColorWriteCreateInfoEXT is not provided, or otherwise it's taken from that. This change fixes the UI (and HTML export) where the color mask was output as `____` in such situations regardless of what mask was dynamically set.
d89f428 to
c09774e
Compare
😮 Unbelievable Thanks for pointing that out. I made an attempt at taking that struct into account by finding my way via |
baldurk
left a comment
There was a problem hiding this comment.
I think this looks good now, but I should probably write a test for the different combinations of static/dynamic and one set of states leading into the other etc.
When the color write enable state (from VK_EXT_color_write_enable) is
not dynamic (i.e the extension is not used),
VulkanRenderState::colorWriteEnable was initialized from pipeline's
color mask info. However, this information should be ignored if color
write mask is dynamic (with shader object / EDS3).
Instead, if color write enable state is not dynamic, it can be
implicitly considered to be true if VkPipelineColorWriteCreateInfoEXT is
not provided, or otherwise it's taken from that.
This change fixes the UI (and HTML export) where the color mask was
output as
____in such situations regardless of what mask wasdynamically set.