GPU: Move gl_FragStencilRefARB to be scanned and added to created info

This commit is contained in:
Clément Foucault
2025-09-30 21:33:33 +02:00
parent 723f4bc549
commit 7ad9a2a72b
4 changed files with 6 additions and 3 deletions

View File

@@ -49,6 +49,7 @@ static uint64_t hash(const std::string &name)
enum Builtin : uint64_t {
FragCoord = hash("gl_FragCoord"),
FragStencilRef = hash("gl_FragStencilRefARB"),
FrontFacing = hash("gl_FrontFacing"),
GlobalInvocationID = hash("gl_GlobalInvocationID"),
InstanceID = hash("gl_InstanceID"),
@@ -1345,6 +1346,7 @@ class Preprocessor {
using namespace metadata;
/* TODO: This can trigger false positive caused by disabled #if blocks. */
std::string tokens[] = {"gl_FragCoord",
"gl_FragStencilRefARB",
"gl_FrontFacing",
"gl_GlobalInvocationID",
"gl_InstanceID",

View File

@@ -446,6 +446,7 @@ enum class BuiltinBits {
* \note Emulated on OpenGL.
*/
BARYCENTRIC_COORD = (1 << 0),
STENCIL_REF = (1 << 1),
FRAG_COORD = (1 << 2),
FRONT_FACING = (1 << 4),
GLOBAL_INVOCATION_ID = (1 << 5),

View File

@@ -77,6 +77,8 @@ struct GPUSource {
switch (builtin) {
case Builtin::FragCoord:
return BuiltinBits::FRAG_COORD;
case Builtin::FragStencilRef:
return BuiltinBits::STENCIL_REF;
case Builtin::FrontFacing:
return BuiltinBits::FRONT_FACING;
case Builtin::GlobalInvocationID:

View File

@@ -556,9 +556,7 @@ bool MTLShader::generate_msl_from_glsl(const shader::ShaderCreateInfo *info)
shd_builder_->glsl_fragment_source_.find("gl_FragDepth") !=
std::string::npos;
/* TODO(fclem): Add to create info. */
msl_iface.uses_gl_FragStencilRefARB = shd_builder_->glsl_fragment_source_.find(
"gl_FragStencilRefARB") != std::string::npos;
msl_iface.uses_gl_FragStencilRefARB = bool(info->builtins_ & BuiltinBits::STENCIL_REF);
msl_iface.depth_write = info->depth_write_;