Page MenuHome

Fix T97086: corrupted UVs with GPU subdivision
ClosedPublic

Authored by Kévin Dietrich (kevindietrich) on May 30 2022, 4:44 PM.

Details

Summary

When multiple objects are in edit mode, UVs for the objects, except for
the first one (in rendering order) appear corrupted. The corruption is
because the UVs are not evaluated as the compute shader is not bound,
thus we read unitialized memory.

We keep track of the currently bound shader in the GPU context in order
to avoid unnecessary shader switches in case the same shader is used in
consecutive calls. However, the shader used by the OpenSubdiv evaluator
is not part of Blender and therefore not tracked via the GPU context.

When extracting UVs for multiple objects, we only ever run a single
shader (FVar evaluation). However, between the compute calls, we also
call the OpenSubdiv stencil evaluation shader, which uses glUseProgram
modifying the current program, outside of our control, which then also
unbinds the Blender compute shader making the compute dispatch fail ("No
active compute shader").

The fact that extracting the UVs for the first rendered object works is
because another (Blender) shader was bound in the GPU context prior to
our binding of our evaluation shader.

To fix this, we remember, in the OpenSubdiv evaluator, the current
program so that it can be reset after the stencil program is done.

Diff Detail

Repository
rB Blender
Branch
fix_T97086_corrupted_gpu_subdiv_uvs (branched from master)
Build Status
Buildable 22325
Build 22325: arc lint + arc unit

Event Timeline

Kévin Dietrich (kevindietrich) requested review of this revision.May 30 2022, 4:44 PM
Kévin Dietrich (kevindietrich) created this revision.

Why not apply the same fix to the patch evaluation, seems like a trivial change?

Apply similar change to patch evaluation routine. No real reason
to not do it now, indeed.

This revision is now accepted and ready to land.May 30 2022, 5:51 PM