From: Mikko Rasa Date: Wed, 17 Nov 2021 13:34:53 +0000 (+0200) Subject: Use OriginUpperLeft execution mode on Vulkan as required by the spec X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=0d5ff7918d50092d8cf2e1b8f7af1d7d29b6eb9b;p=libs%2Fgl.git Use OriginUpperLeft execution mode on Vulkan as required by the spec --- diff --git a/source/glsl/compiler.cpp b/source/glsl/compiler.cpp index a447c9c9..0e26a163 100644 --- a/source/glsl/compiler.cpp +++ b/source/glsl/compiler.cpp @@ -158,7 +158,7 @@ vector 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(); } diff --git a/source/glsl/spirv.cpp b/source/glsl/spirv.cpp index 13c58a69..7f99ebb3 100644 --- a/source/glsl/spirv.cpp +++ b/source/glsl/spirv.cpp @@ -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); diff --git a/source/glsl/spirv.h b/source/glsl/spirv.h index 59c7b50b..addf8970 100644 --- a/source/glsl/spirv.h +++ b/source/glsl/spirv.h @@ -70,6 +70,7 @@ private: bool operator<(const ConstantKey &) const; }; + Features features; Stage *stage = 0; FunctionDeclaration *current_function = 0; std::vector interface_layouts; @@ -106,7 +107,7 @@ private: public: SpirVGenerator(); - void apply(Module &); + void apply(Module &, const Features &); const std::vector &get_code() const { return content.code; } private: diff --git a/source/glsl/spirvconstants.h b/source/glsl/spirvconstants.h index 33d705e2..9935b43e 100644 --- a/source/glsl/spirvconstants.h +++ b/source/glsl/spirvconstants.h @@ -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,