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

Issue with RelaxedPrecision and OpCompositeConstruct #151

Open
mbechard opened this issue Jul 5, 2022 · 6 comments
Open

Issue with RelaxedPrecision and OpCompositeConstruct #151

mbechard opened this issue Jul 5, 2022 · 6 comments

Comments

@mbechard
Copy link

mbechard commented Jul 5, 2022

I have the following shader:

                              Capability Shader
                              Capability Sampled1D
               1:             ExtInstImport  "GLSL.std.450"
                              MemoryModel Logical GLSL450
                              EntryPoint Fragment 4  "main" 9
                              ExecutionMode 4 OriginUpperLeft
                              Source GLSL 430
                              SourceExtension  "GL_EXT_nonuniform_qualifier"
                              SourceExtension  "GL_GOOGLE_cpp_style_line_directive"
                              SourceExtension  "GL_GOOGLE_include_directive"
                              Name 4  "main"
                              Name 9  "fragColor"
                              Name 11  "gl_DefaultUniformBlock"
                              MemberName 11(gl_DefaultUniformBlock) 0  "uTDPass"
                              MemberName 11(gl_DefaultUniformBlock) 1  "uTDCurrentDepth"
                              MemberName 11(gl_DefaultUniformBlock) 2  "exampleUniform"
                              Name 13  ""
                              Decorate 9(fragColor) RelaxedPrecision
                              Decorate 9(fragColor) Location 0
                              MemberDecorate 11(gl_DefaultUniformBlock) 0 Offset 0
                              MemberDecorate 11(gl_DefaultUniformBlock) 1 Offset 4
                              MemberDecorate 11(gl_DefaultUniformBlock) 2 RelaxedPrecision
                              MemberDecorate 11(gl_DefaultUniformBlock) 2 Offset 8
                              Decorate 11(gl_DefaultUniformBlock) Block
                              Decorate 17 RelaxedPrecision
                              Decorate 18 RelaxedPrecision
               2:             TypeVoid
               3:             TypeFunction 2
               6:             TypeFloat 32
               7:             TypeVector 6(float) 4
               8:             TypePointer Output 7(fvec4)
    9(fragColor):      8(ptr) Variable Output
              10:             TypeInt 32 1
11(gl_DefaultUniformBlock):             TypeStruct 10(int) 10(int) 6(float)
              12:             TypePointer PushConstant 11(gl_DefaultUniformBlock)
              13:     12(ptr) Variable PushConstant
              14:     10(int) Constant 2
              15:             TypePointer PushConstant 6(float)
         4(main):           2 Function None 3
               5:             Label
              16:     15(ptr) AccessChain 13 14
              17:    6(float) Load 16
              18:    7(fvec4) CompositeConstruct 17 17 17 17
                              Store 9(fragColor) 18
                              Return
                              FunctionEnd

Reflection fails since it's trying to reflect the RelaxedPrecision on result_id 18, however ParseNodes() does not assign the result_id to OpCompositeConstruct nodes. Isn't OpCompositeConstruct a load/store operation, and should be treated as such? The SPIR-V is coming out of GLSLang, and passes the SPIR-V validator.

Thanks

@mbechard
Copy link
Author

mbechard commented Jul 5, 2022

Also, shouldn't it also be handled for the arithmetic operators such as FSub, along with handling ExtInst cases, since most (all?) of the GLSL instruction extensions could also be decorated with RelaxedPrecision?

@mbechard
Copy link
Author

Sorry for the bump on this, any thoughts? I'd be happy to submit a patch if my understanding is correct.

@shangjiaxuan
Copy link

Sorry for the bump on this, any thoughts? I'd be happy to submit a patch if my understanding is correct.

It seems spirv-reflect doesn't recognize the OpCompositeConstruct op code, and falls through to default, skipping the instruction. Decoration parsing seems to already have relaxed precision flag in the node.

My understanding is that you are right.

@chaoticbob
Copy link
Contributor

Sorry for the late response. Support for RelaxPrecision initially wasn't prioritized because there wasn't a production case. I'll take a look using your shader as an example. If you're able to share more complex cases, it would be helpful.

@mbechard
Copy link
Author

Thanks for taking a look, I don't have a more complex example right now. I think the tricky part would be covering all of the possible cases. I wonder if anything that be pulled from the SPIR-V validator, since it knows to check for instructions where Relaxed Precision is legal and not.

@chaoticbob
Copy link
Contributor

Sorry again for the late response. It looks likeI had missed something you said earlier. If you're still willing to submit a patch - I'd love to take a look.

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

3 participants