Implement relaxed rule for opaque struct members#3365
Implement relaxed rule for opaque struct members#3365arcady-lunarg merged 3 commits intoKhronosGroup:mainfrom
Conversation
|
Looks like ASAN found some issues with your patch, do you want to address them before I take a look to review the changes? Also, is there some sequencing needed between this and the PR to then GLSL repo? |
|
I wanted to try and merge both PR at about the same time so repos can remain in sync, but if changes are requested on the GLSL part, this could mean additional work on this side. I don't mind waiting on the other one if you don't want to invest time on a change that's not yet approved. I haven't entirely figured out how memory ownership is handled within the codebase, so I figured there would be some leaks in the end. I'll look into them by the end of the week. |
Some classes use the |
ncesario-lunarg
left a comment
There was a problem hiding this comment.
I think some of the logic around newParams in the vkRelaxedRemapFunctionParameter needs to be reworked. Let me know if you have more questions about memory allocations in the parser.
| memberType->getQualifier().storage = param.type->getQualifier().storage; | ||
| memberType->clearArraySizes(); | ||
|
|
||
| TParameter* memberParam = new TParameter(); |
There was a problem hiding this comment.
TParameter does not use the pool allocator (by default at least), so this is using the standard allocator and would need to be cleaned up. I'm not sure if this is the right way to go about this. You could use the pool allocator, but it seems like you could also retrieve the necessary parameters from function after vkRelaxedRemapFunctionParameter is called (though you may need to add an additional field to TParameter to pick out the parameters you want)?
There was a problem hiding this comment.
I replaced the last function parameter with a vector of integer to avoid changing TParameter, but maybe it would be better to properly flag parameters that are implicitly created during this pass ?
|
|
||
| ForEachOpaque(type, identifier, | ||
| [&publicType, &loc, this](const TType& type, const TString& path) { | ||
| TString& structMemberName = *(new TString(path)); |
There was a problem hiding this comment.
This is another spot ASAN is complaining about. You can use NewPoolTString, but does this need to be dynamically allocated here?
There was a problem hiding this comment.
True, this should be a straight copy
Nevermind. It looks like we need the allocation, because declareVariable takes a TString& as argument
c62630d to
9ab942f
Compare
|
Thanks for reviewing ! My latest changes should fix leaks |
arcady-lunarg
left a comment
There was a problem hiding this comment.
I have a couple of minor nits but overall this seems fine. It's a lot of fairly complicated code but that code is only used in relaxed mode.
| $1.function->addParameter(param); | ||
| $$.function = $1.function; | ||
| $$.intermNode = $2; | ||
| if (!(parseContext.spvVersion.vulkan > 0 |
There was a problem hiding this comment.
I would prefer you invert the condition of the if-statement so that it's not negated, I think it's easier to read "if (vulkanRelaxed && containsOpaque) { // do something unusual } else { // do the normal thing".
| } | ||
|
|
||
| bool TParseContext::vkRelaxedRemapUniformVariable(const TSourceLoc& loc, TString& identifier, const TPublicType&, | ||
| bool TParseContext::vkRelaxedRemapUniformVariable(const TSourceLoc& loc, TString& identifier, const TPublicType& publicType, |
There was a problem hiding this comment.
publicType appears to be unused, you should keep it anonymous to prevent a compiler warning.
There was a problem hiding this comment.
It's forwarded to vkRelaxedRemapUniformMembers. I looked across the file for another publicType that seemed unused but didn't find any.
| $$.intermNode = parseContext.intermediate.growAggregate($1.intermNode, $3, $2.loc); | ||
| if (!(parseContext.spvVersion.vulkan > 0 | ||
| && parseContext.spvVersion.vulkanRelaxed) | ||
| || !$3->getType().containsOpaque()) |
There was a problem hiding this comment.
Same comment re inverting the condition to make it clearer.
arcady-lunarg
left a comment
There was a problem hiding this comment.
Thanks, looks good now.
This PR is a companion to another PR we recently opened on
KhronosGroup/GLSL: KhronosGroup/GLSL#218It implements the procedure described in the suggested changes to
GL_EXT_vulkan_glsl_relaxed.Samplers are extracted out of structures and moved to the topmost level available. In the context of uniform, that's the global uniform block. For structures passed as function parameters, we create invisible parameters and properly route arguments to them.
We also extend the
vk.relaxed.fragtest shader to demonstrate these added capabilities.