new feature level API for backends (#5784)

* new feature level API for backends

backend can now return a "feature level", each level corresponds to a
"bundle" of features.
Level1: ES3.0 capabilities
Level2: ES3.1 capabilities + 31 textures + cubemap arrays

Currently metal always returns level 1, GL and Vulkan return level 2
if 31 textures or more are supported.

* Add public APIs for feature levels

* Add infrastructure to check feature levels in materials

* validate material feature level on use

The validation is done when creating a renderable. If the engine doesn't
support the material's feature level, an exception is thrown (or assert
if exceptions are not enabled).

* material documentation

* activate ESSL 3.10 for feature level 2

also generate #defines to identify available feature levels

* support for cubemap arrays in the public API


if feature level 2 is supported, cubemap arrays can be used from the
public API.

* add release notes
This commit is contained in:
Mathias Agopian
2022-08-17 10:14:26 -07:00
committed by GitHub
parent 7c092a8714
commit b2ec57776d
40 changed files with 513 additions and 114 deletions
+17 -6
View File
@@ -16,6 +16,8 @@
#include "CodeGenerator.h"
#include "MaterialInfo.h"
#include "generated/shaders.h"
#include <utils/sstream.h>
@@ -37,25 +39,27 @@ io::sstream& CodeGenerator::generateSeparator(io::sstream& out) {
return out;
}
io::sstream& CodeGenerator::generateProlog(io::sstream& out, ShaderType type,
bool hasExternalSamplers) const {
utils::io::sstream& CodeGenerator::generateProlog(utils::io::sstream& out, ShaderType type,
MaterialInfo const& info) const {
switch (mShaderModel) {
case ShaderModel::MOBILE:
// Vulkan requires version 310 or higher
if (mTargetLanguage == TargetLanguage::SPIRV) {
if (mTargetLanguage == TargetLanguage::SPIRV ||
info.featureLevel >= FeatureLevel::FEATURE_LEVEL_2) {
// Vulkan requires layout locations on ins and outs, which were not supported
// in the OpenGL 4.1 GLSL profile.
out << "#version 310 es\n\n";
} else {
out << "#version 300 es\n\n";
}
if (hasExternalSamplers) {
if (info.hasExternalSamplers) {
out << "#extension GL_OES_EGL_image_external_essl3 : require\n\n";
}
out << "#define TARGET_MOBILE\n";
break;
case ShaderModel::DESKTOP:
if (mTargetLanguage == TargetLanguage::SPIRV) {
if (mTargetLanguage == TargetLanguage::SPIRV ||
info.featureLevel >= FeatureLevel::FEATURE_LEVEL_2) {
// Vulkan requires binding specifiers on uniforms and samplers, which were not
// supported in the OpenGL 4.1 GLSL profile.
out << "#version 450 core\n\n";
@@ -91,10 +95,17 @@ io::sstream& CodeGenerator::generateProlog(io::sstream& out, ShaderType type,
out << "#define FILAMENT_OPENGL_SEMANTICS\n";
}
out << '\n';
out << "#define FILAMENT_FEATURE_LEVEL_1 1\n";
out << "#define FILAMENT_FEATURE_LEVEL_2 2\n";
out << "#define FILAMENT_FEATURE_LEVEL FILAMENT_FEATURE_LEVEL_" << (int)info.featureLevel << "\n";
out << '\n';
if (mTargetApi == TargetApi::VULKAN ||
mTargetApi == TargetApi::METAL ||
(mTargetApi == TargetApi::OPENGL && mShaderModel == ShaderModel::DESKTOP)) {
(mTargetApi == TargetApi::OPENGL && mShaderModel == ShaderModel::DESKTOP) ||
info.featureLevel >= FeatureLevel::FEATURE_LEVEL_2) {
out << "#define FILAMENT_HAS_FEATURE_TEXTURE_GATHER\n";
}