Page MenuHome

GPU: Avoid undocumented/fragile dependency on shader enumerator order
ClosedPublic

Authored by Julian Eisel (Severin) on Oct 20 2022, 12:57 PM.

Details

Summary

Previously this was using GPU_SHADER_TEXT as default value indicating
an "unset" state. This wasn't documented in the definition (and so
D16284 added a new enumerator that broke this). Plus code was assuming
this enumerator would always have the value 0 without specifying this in
the definition either.

In this case it's easy to not rely on the enum value at all, and just
use std::optional to add a "unset" state.

Diff Detail

Repository
rB Blender

Event Timeline

Julian Eisel (Severin) requested review of this revision.Oct 20 2022, 12:57 PM
Julian Eisel (Severin) created this revision.

Context: When D16284 added a new enumerator before GPU_SHADER_TEXT, the splash looked like this, and there were numerous other artifacts:


Same when explicitly setting GPU_SHADER_TEXT = 1 in the definition (because the implementation implicitly assumed it to be 0).

This revision is now accepted and ready to land.Oct 20 2022, 1:04 PM