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

Autodesk: Skip use of geometry shader for patch tessellation when possible #3422

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

erikaharrison-adsk
Copy link
Contributor

Description of Change(s)

This updates the shader configuration for surface patches, for better performance. The geometry shader is in most cases omitted except when the display style is HdMeshGeomStyleEdgeOnSurf, in which case a geometry shader is required to render edges of output triangles.

The changes include new tessellation evaluation shaders, and an alternative DisplacementTerminal protocol in order to evaluate displacements correctly in a tessellation shader. Some changes also in codegen to include required supporting code such as interstage elements. Also included here is a TfDebug variable for listing shader keys.

Performance tests indicate approximately 40% speedup on average when rendering this type of geometry on a high-end laptop with an NVidia RTX A3000 GPU.

Link to proposal (if applicable)

  • N/A

Fixes Issue(s)

  • N/A

Checklist

@jesschimein
Copy link
Collaborator

Filed as internal issue #USD-10438

@jesschimein
Copy link
Collaborator

/AzurePipelines run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@tcauchois
Copy link
Contributor

Exciting!

@davidgyu
Copy link
Member

I don't think the TfDebug code introduced here is needed.

It matches existing functionality provided by TF_DEBUG=HDST_DUMP_GLSLFX_CONFIG

@erikaharrison-adsk
Copy link
Contributor Author

@davidgyu PR has been updated based on this feedback.

@jesschimein
Copy link
Collaborator

/AzurePipelines run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

uint8_t tesIndex = 0;
TES[tesIndex++] = _tokens->instancing;

if (geomStyle == HdMeshGeomStyleEdgeOnSurf) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems not quite right. Minimally, this should also test hasBuiltinBarycentrics, which is the only thing that edges need from GS.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, right, when the fragment shader has barycentrics, it can render edges.

vec2 t1 = HdGet_st(i1);
vec2 t2 = HdGet_st(i2);
vec2 t3 = HdGet_st(i3);
vec2 t = InterpolatePrimvar(t0, t1, t2, t3, basis, uv);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The signal driving displacement might not be named st, e.g. an asset like usdImagingGL/testenv/testUsdImagingGLDisplacement/testUsdImagingGLDisplacement.usda will fail during shader compilation since the displacement input coord is named st_faceVarying.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. I'm not quite sure what a comprehensive solution would look like. Will have to think about that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that part of the codeGen texture accessors is delicate. I've been looking into refactoring the displacement terminal a little differently than you have here and I'll tty to share that back with you (possibly next week).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That will help, thanks. I appreciate that.

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

Successfully merging this pull request may close these issues.

5 participants