Previously, when a material was expilicitly built for feature level 0, it was necessary to write ESSL 1.0 code which was incompatible with the OpenGL feature level 1 implementation in Filament. Rather than adjust the Filament implementation so that feature level 1 uses the same workarounds as feature level 0 to emulate GLES 3.0+ features, it's more runtime-efficient to have matc embed ESSL 1.0 and 3.0 shaders as separate chunks and load the corresponding one based on the active feature level. Feature level 0 material shaders must still be written in what is effectively ESSL 1.0. To assist with this, a small set of compatibility definitions are introduced when building the ESSL 3.0 variant. These are virtually all textureXXX() functions, and end up either optimized out or inlined by glslang. One final effect of this change is that external and 3D samplers are now properly supported in feature level 0 materials.
48 lines
1.9 KiB
C++
48 lines
1.9 KiB
C++
/*
|
|
* Copyright (C) 2020 The Android Open Source Project
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#include <fstream>
|
|
#include <iostream>
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include "MaterialParser.h"
|
|
|
|
#include "filament_test_resources.h"
|
|
|
|
using namespace filament;
|
|
|
|
// This test checks that a material compiled with an older version of matc can still be parsed.
|
|
// If this test is failing, it probably means that MATERIAL_VERSION needs to be incremented.
|
|
// After doing so, to fix the test, run filament/test/update_test_material.sh.
|
|
// This will re-compile the test material with the current version of matc.
|
|
// To verify, rebuild and re-run test_material_parser (this test suite).
|
|
TEST(MaterialParser, Parse) {
|
|
MaterialParser parser(backend::ShaderLanguage::ESSL3,
|
|
FILAMENT_TEST_RESOURCES_TEST_MATERIAL_DATA, FILAMENT_TEST_RESOURCES_TEST_MATERIAL_SIZE);
|
|
MaterialParser::ParseResult materialOk = parser.parse();
|
|
|
|
EXPECT_TRUE(materialOk == MaterialParser::ParseResult::SUCCESS) <<
|
|
"Material filament/test/test_material.filamat could not be parsed by MaterialParser." << std::endl <<
|
|
"Does MATERIAL_VERSION need to be updated?" << std::endl <<
|
|
"See instructions in filament_test_material_parser.cpp" << std::endl;
|
|
}
|
|
|
|
int main(int argc, char** argv) {
|
|
::testing::InitGoogleTest(&argc, argv);
|
|
return RUN_ALL_TESTS();
|
|
}
|