]> git.tdb.fi Git - libs/gl.git/commitdiff
Use OriginUpperLeft execution mode on Vulkan as required by the spec
authorMikko Rasa <tdb@tdb.fi>
Wed, 17 Nov 2021 13:34:53 +0000 (15:34 +0200)
committerMikko Rasa <tdb@tdb.fi>
Wed, 17 Nov 2021 13:48:20 +0000 (15:48 +0200)
source/glsl/compiler.cpp
source/glsl/spirv.cpp
source/glsl/spirv.h
source/glsl/spirvconstants.h

index a447c9c9adbb5c07550bfb090b0923552a1d916a..0e26a16353b46bf1ae73876fc08be92b20621b2d 100644 (file)
@@ -158,7 +158,7 @@ vector<uint32_t> Compiler::get_combined_spirv() const
        if(!compiled)
                throw invalid_operation("Compiler::get_combined_spirv");
        SpirVGenerator gen;
-       gen.apply(*module);
+       gen.apply(*module, features);
        return gen.get_code();
 }
 
index 13c58a695ab3668d9c0a605ce679f1d00565a997..7f99ebb3d9ecc61b737739542feed5a72994633f 100644 (file)
@@ -135,8 +135,9 @@ SpirVGenerator::SpirVGenerator():
        writer(content)
 { }
 
-void SpirVGenerator::apply(Module &module)
+void SpirVGenerator::apply(Module &module, const Features &f)
 {
+       features = f;
        use_capability(CAP_SHADER);
 
        for(Stage &s: module.stages)
@@ -1745,7 +1746,10 @@ void SpirVGenerator::visit_entry_point(FunctionDeclaration &func, Id func_id)
        writer.end_op(OP_ENTRY_POINT);
 
        if(stage->type==Stage::FRAGMENT)
-               writer.write_op(content.exec_modes, OP_EXECUTION_MODE, func_id, EXEC_ORIGIN_LOWER_LEFT);
+       {
+               SpirVExecutionMode origin = (features.target_api==VULKAN ? EXEC_ORIGIN_UPPER_LEFT : EXEC_ORIGIN_LOWER_LEFT);
+               writer.write_op(content.exec_modes, OP_EXECUTION_MODE, func_id, origin);
+       }
        else if(stage->type==Stage::GEOMETRY)
                use_capability(CAP_GEOMETRY);
 
index 59c7b50b0cc45fede654eff5d3580840c5eecf1a..addf8970315c5fb68e6d05d31c55c9b467ebf6c5 100644 (file)
@@ -70,6 +70,7 @@ private:
                bool operator<(const ConstantKey &) const;
        };
 
+       Features features;
        Stage *stage = 0;
        FunctionDeclaration *current_function = 0;
        std::vector<const InterfaceLayout *> interface_layouts;
@@ -106,7 +107,7 @@ private:
 public:
        SpirVGenerator();
 
-       void apply(Module &);
+       void apply(Module &, const Features &);
        const std::vector<Word> &get_code() const { return content.code; }
 
 private:
index 33d705e22383971ccd273a3d8d4cc77f1b2fc9b3..9935b43e592d3081f4e1ad7493d22df08d37644c 100644 (file)
@@ -169,6 +169,7 @@ enum SpirVCapability
 
 enum SpirVExecutionMode
 {
+       EXEC_ORIGIN_UPPER_LEFT = 7,
        EXEC_ORIGIN_LOWER_LEFT = 8,
        EXEC_INPUT_POINTS = 19,
        EXEC_INPUT_LINES = 20,