Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Possible bug when writing the vertex fetch instructions #27
I have a vertex attribute with format equal to VK_FORMAT_A2B10G10R10_SNORM_PACK32. My program fails on pipeline creation. Did some digging and I hit an assertion deep into LLVM code.
The issue starts in:
// Insert alpha channel: %vf0 = insertelement %vf0, %a, 3
The pAlpha is of type FloatTyID and vertexFetch is VectorTyID.
Later on there is this assert:
assert(isValidOperands(Vec, Elt, Index) &&
which states that "Second operand of insertelement must be vector element type" which is probably not.
If you do a quick code inspection, is this piece of code correct? If yes I'll dig some more and create a repro case.
It seems it is a bug in our driver. vertexFetch shouldbe VectorTyID with integer type. but pAlpha is float now. please try to change the type to Int32Ty in previous bitcast instruction
// %a = bitcast %a to i32
please let me know if it can work in your case.
After some more digging it seems something is still a bit off.
As I mentioned before I use VK_FORMAT_A2B10G10R10_SNORM_PACK32 (for tangents where w component holds the sign of the bitangent). I've done an experiment where I hardcode 0b11 to the alpha component of this format when building my assets. In theory, that will return -1.0 inside the vertex shader. Nevertheless the shader reports +1.0.
In Mesa GL and nVidia GL the behaviour seems the expected. In AMDVLK and -oddly enough- in RADV it seems it doesn't.
By looking at your comments in llpcVertexFetch.cpp I see that there are some annoyances around the sign of alpha.
sorry for delay response, I agree this code is too tricky. it is easy to cause bugs after LLVM optimization.
Can you try following code in "else if (pFormatInfo->nfmt == BUF_NUM_FORMAT_SNORM)"
pAlpha = new BitCastInst(pAlpha, m_pContext->FloatTy(), "", pInsertPos);
ps: above code isn't tested yet. please let me know if doesn't work.
please try again, thanks!