DiligentGraphics/DiligentCore

HLSL2GLSL geometry shader `SV_PrimitiveID` support.

Closed this issue · 4 comments

Hi, i've recently found a small issue in HLSL2GLSL conversion.

The code here assumes the geometry shader arguments consists only of one input and one output. However in my geometry shader, there's some hlsl semantic variables. Specially, i'm trying to use SV_PrimitiveID here. It would be nice if this bug can be fixed, thanks!

Geometry shader can only have one input and one output, but it can be a struct where you can pack all required data. Please take a look at Tutorial 07.

@TheMostDiligent Hello, do you consider it a bug that FXC accepts additional semantic variables as input? Actually the code works fine under DX11 and DX12 backend. I didn't try out DXC status though.

I googled it and found that there's other examples that exhibit similar usage, like in this tutorial 12.2.4 SV_PrimitiveID, the example code exhibit a similar usage:

[maxvertexcount(4)]

void GS(point VertexOut gin[1],

uint primID : SV_PrimitiveID,

inout TriangleStream<GeoOut> triStream)

I'm not sure whether SV_PrimitiveID can be included within the vertex output struct because it's not part of the vertex shader calculation, it's system generated by the pipeline instead... Maybe i can try it out.

If this is an expected limitation i can workaround this... though a little unfortunate.

EDIT: Using "maxvertexcount SV_PrimitiveId" as google keyword, it seems others are all writing code in the same way. I'm not sure if this is a special case or something.

OK, it looks like there is indeed an issue with the converter: SV_PrimitiveId must be added as another input to GS function.

@TheMostDiligent any updates on this issue?