Path: blob/main/glslc/test/option_fhlsl_functionality1.py
1560 views
# Copyright 2018 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# An HLSL shader with a counter buffer with a counter increment.19# Glslang doesn't automatically assign a binding to the counter, and20# it doesn't understand [[vk::counter_binding(n)]], so compile this21# with --auto-bind-uniforms.22# See https://github.com/KhronosGroup/glslang/issues/161623HLSL_VERTEX_SHADER_WITH_COUNTER_BUFFER = """24RWStructuredBuffer<int> Ainc;25float4 main() : SV_Target0 {26return float4(Ainc.IncrementCounter(), 0, 1, 2);27}28"""293031@inside_glslc_testsuite('OptionFHlslFunctionality1')32class TestHlslFunctionality1MentionsExtension(expect.ValidAssemblyFileWithSubstr):33"""Tests that -fhlsl_functionality1 enabled SPV_GOOGLE_hlsl_functionality1."""3435shader = FileShader(HLSL_VERTEX_SHADER_WITH_COUNTER_BUFFER, '.frag')36glslc_args = ['-S', '-x', 'hlsl', '-fhlsl_functionality1',37'-fauto-bind-uniforms', shader]38expected_assembly_substr = 'OpExtension "SPV_GOOGLE_hlsl_functionality1"'394041@inside_glslc_testsuite('OptionFHlslFunctionality1')42class TestHlslFunctionality1DecoratesCounter(expect.ValidAssemblyFileWithSubstr):43"""Tests that -fhlsl_functionality1 decorates the output target"""4445shader = FileShader(HLSL_VERTEX_SHADER_WITH_COUNTER_BUFFER, '.frag')46glslc_args = ['-S', '-x', 'hlsl', '-fhlsl_functionality1',47'-fauto-bind-uniforms', shader]48expected_assembly_substr = 'OpDecorateString'495051## Next tests use the option with the hypen instead of underscore.5253@inside_glslc_testsuite('OptionFHlslFunctionality1')54class TestHlslHyphenFunctionality1MentionsExtension(expect.ValidAssemblyFileWithSubstr):55"""Tests that -fhlsl-functionality1 enabled SPV_GOOGLE_hlsl_functionality1."""5657shader = FileShader(HLSL_VERTEX_SHADER_WITH_COUNTER_BUFFER, '.frag')58glslc_args = ['-S', '-x', 'hlsl', '-fhlsl_functionality1',59'-fauto-bind-uniforms', shader]60expected_assembly_substr = 'OpExtension "SPV_GOOGLE_hlsl_functionality1"'616263@inside_glslc_testsuite('OptionFHlslFunctionality1')64class TestHlslHyphenFunctionality1DecoratesCounter(expect.ValidAssemblyFileWithSubstr):65"""Tests that -fhlsl-functionality1 decorates the output target"""6667shader = FileShader(HLSL_VERTEX_SHADER_WITH_COUNTER_BUFFER, '.frag')68glslc_args = ['-S', '-x', 'hlsl', '-fhlsl_functionality1',69'-fauto-bind-uniforms', shader]70expected_assembly_substr = 'OpDecorateString'717273