Path: blob/main/glslc/test/option_dash_fnan_clamp.py
1560 views
# Copyright 2019 The Shaderc Authors. All rights reserved.1#2# Licensed under the Apache License, Version 2.0 (the "License");3# you may not use this file except in compliance with the License.4# You may obtain a copy of the License at5#6# http://www.apache.org/licenses/LICENSE-2.07#8# Unless required by applicable law or agreed to in writing, software9# distributed under the License is distributed on an "AS IS" BASIS,10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.11# See the License for the specific language governing permissions and12# limitations under the License.1314import expect15from glslc_test_framework import inside_glslc_testsuite16from placeholder import FileShader1718# A GLSL shader using the clamp, max, and min builtin functions.19GLSL_FRAG_SHADER_WITH_CLAMP = """#version 45020layout(location=0) in vec4 i;21layout(location=0) out vec4 o;22void main() {23o = clamp(i, vec4(0.5), vec4(1.0))24+ max(i, vec4(0.5))25+ min(i, vec4(0.5));26}27"""282930@inside_glslc_testsuite('OptionFNanClamp')31class TestClampMapsToFClampByDefault(expect.ValidAssemblyFileWithSubstr):32shader = FileShader(GLSL_FRAG_SHADER_WITH_CLAMP, '.frag')33glslc_args = ['-S', shader]34expected_assembly_substr = 'OpExtInst %v4float %1 FClamp'353637@inside_glslc_testsuite('OptionFNanClamp')38class TestMaxMapsToFMaxByDefault(expect.ValidAssemblyFileWithSubstr):39shader = FileShader(GLSL_FRAG_SHADER_WITH_CLAMP, '.frag')40glslc_args = ['-S', shader]41expected_assembly_substr = 'OpExtInst %v4float %1 FMax'424344@inside_glslc_testsuite('OptionFNanClamp')45class TestMinMapsToFMinByDefault(expect.ValidAssemblyFileWithSubstr):46shader = FileShader(GLSL_FRAG_SHADER_WITH_CLAMP, '.frag')47glslc_args = ['-S', shader]48expected_assembly_substr = 'OpExtInst %v4float %1 FMin'495051@inside_glslc_testsuite('OptionFNanClamp')52class TestClampMapsToNClampWithFlag(expect.ValidAssemblyFileWithSubstr):53shader = FileShader(GLSL_FRAG_SHADER_WITH_CLAMP, '.frag')54glslc_args = ['-S', '-fnan-clamp', shader]55expected_assembly_substr = 'OpExtInst %v4float %1 NClamp'5657@inside_glslc_testsuite('OptionFNanClamp')58class TestMaxMapsToNMaxWithFlag(expect.ValidAssemblyFileWithSubstr):59shader = FileShader(GLSL_FRAG_SHADER_WITH_CLAMP, '.frag')60glslc_args = ['-S', '-fnan-clamp', shader]61expected_assembly_substr = 'OpExtInst %v4float %1 NMax'626364@inside_glslc_testsuite('OptionFNanClamp')65class TestMinMapsToNMinWithFlag(expect.ValidAssemblyFileWithSubstr):66shader = FileShader(GLSL_FRAG_SHADER_WITH_CLAMP, '.frag')67glslc_args = ['-S', '-fnan-clamp', shader]68expected_assembly_substr = 'OpExtInst %v4float %1 NMin'697071