]> git.tdb.fi Git - libs/gl.git/commitdiff
Reflect builtin decorators from SPIR-V modules
authorMikko Rasa <tdb@tdb.fi>
Sun, 10 Oct 2021 14:03:02 +0000 (17:03 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 10 Oct 2021 15:35:28 +0000 (18:35 +0300)
source/core/module.cpp
source/core/module.h

index eaed8a45c7b7ed04003e996d28bcd7c85b99e68c..2326a5e7fd3dcf73c8a9f4e73ba191cd2a0acda3 100644 (file)
@@ -37,6 +37,7 @@ enum SpirVConstants
        DECO_SPEC_ID = 1,
        DECO_ARRAY_STRIDE = 6,
        DECO_MATRIX_STRIDE = 7,
+       DECO_BUILTIN = 11,
        DECO_LOCATION = 30,
        DECO_BINDING = 33,
        DECO_DESCRIPTOR_SET = 34,
@@ -504,6 +505,9 @@ void SpirVModule::Reflection::reflect_decorate(CodeIterator op)
        case DECO_ARRAY_STRIDE:
                types[id].array_stride = *op;
                break;
+       case DECO_BUILTIN:
+               variables[id].builtin = static_cast<BuiltinSemantic>(*op);
+               break;
        case DECO_LOCATION:
                variables[id].location = *op;
                break;
@@ -531,6 +535,9 @@ void SpirVModule::Reflection::reflect_member_decorate(CodeIterator op)
        case DECO_MATRIX_STRIDE:
                member.matrix_stride = *op;
                break;
+       case DECO_BUILTIN:
+               member.builtin = static_cast<BuiltinSemantic>(*op);
+               break;
        case DECO_OFFSET:
                member.offset = *op;
                break;
index 7713d3ce0a77a79af54b61298868a31b24c77d1a..9ac54d328ee42a86b97fed32e82383a171138739 100644 (file)
@@ -79,6 +79,15 @@ public:
                OUTPUT = 3
        };
 
+       enum BuiltinSemantic
+       {
+               NOT_BUILTIN = -1,
+               POSITION = 0,
+               CLIP_DISTANCE = 3,
+               LAYER = 9,
+               FRAG_DEPTH = 22
+       };
+
        struct Constant;
        struct Structure;
        struct Variable;
@@ -100,6 +109,7 @@ public:
                const Constant *array_size_spec = 0;
                unsigned array_stride = 0;
                unsigned matrix_stride = 0;
+               BuiltinSemantic builtin = NOT_BUILTIN;
        };
 
        struct Structure
@@ -120,6 +130,7 @@ public:
                int location = -1;
                int descriptor_set = -1;
                int binding = -1;
+               BuiltinSemantic builtin = NOT_BUILTIN;
 
                bool operator==(const Variable &) const;
        };