diff --git a/src/tint/lang/core/ir/var.h b/src/tint/lang/core/ir/var.h index b27451433e..8c597bb262 100644 --- a/src/tint/lang/core/ir/var.h +++ b/src/tint/lang/core/ir/var.h @@ -40,7 +40,7 @@ namespace tint::core::ir { /// A var instruction in the IR. -class Var final : public Castable> { +class Var : public Castable> { public: /// The offset in Operands() for the initializer static constexpr size_t kInitializerOperandOffset = 0; diff --git a/src/tint/lang/glsl/ir/BUILD.bazel b/src/tint/lang/glsl/ir/BUILD.bazel index ac3a1dc26e..f040e2a504 100644 --- a/src/tint/lang/glsl/ir/BUILD.bazel +++ b/src/tint/lang/glsl/ir/BUILD.bazel @@ -40,10 +40,12 @@ cc_library( name = "ir", srcs = [ "builtin_call.cc", + "combined_texture_sampler_var.cc", "member_builtin_call.cc", ], hdrs = [ "builtin_call.h", + "combined_texture_sampler_var.h", "member_builtin_call.h", ], deps = [ @@ -76,6 +78,7 @@ cc_library( alwayslink = True, srcs = [ "builtin_call_test.cc", + "combined_texture_sampler_var_test.cc", "member_builtin_call_test.cc", ], deps = [ diff --git a/src/tint/lang/glsl/ir/BUILD.cmake b/src/tint/lang/glsl/ir/BUILD.cmake index 2ede78844f..0e8cd986d1 100644 --- a/src/tint/lang/glsl/ir/BUILD.cmake +++ b/src/tint/lang/glsl/ir/BUILD.cmake @@ -41,6 +41,8 @@ tint_add_target(tint_lang_glsl_ir lib lang/glsl/ir/builtin_call.cc lang/glsl/ir/builtin_call.h + lang/glsl/ir/combined_texture_sampler_var.cc + lang/glsl/ir/combined_texture_sampler_var.h lang/glsl/ir/member_builtin_call.cc lang/glsl/ir/member_builtin_call.h ) @@ -77,6 +79,7 @@ tint_target_add_external_dependencies(tint_lang_glsl_ir lib ################################################################################ tint_add_target(tint_lang_glsl_ir_test test lang/glsl/ir/builtin_call_test.cc + lang/glsl/ir/combined_texture_sampler_var_test.cc lang/glsl/ir/member_builtin_call_test.cc ) diff --git a/src/tint/lang/glsl/ir/BUILD.gn b/src/tint/lang/glsl/ir/BUILD.gn index 65c38dac59..eaeb8f7ea1 100644 --- a/src/tint/lang/glsl/ir/BUILD.gn +++ b/src/tint/lang/glsl/ir/BUILD.gn @@ -47,6 +47,8 @@ libtint_source_set("ir") { sources = [ "builtin_call.cc", "builtin_call.h", + "combined_texture_sampler_var.cc", + "combined_texture_sampler_var.h", "member_builtin_call.cc", "member_builtin_call.h", ] @@ -77,6 +79,7 @@ if (tint_build_unittests) { tint_unittests_source_set("unittests") { sources = [ "builtin_call_test.cc", + "combined_texture_sampler_var_test.cc", "member_builtin_call_test.cc", ] deps = [ diff --git a/src/tint/lang/glsl/ir/combined_texture_sampler_var.cc b/src/tint/lang/glsl/ir/combined_texture_sampler_var.cc new file mode 100644 index 0000000000..d862710894 --- /dev/null +++ b/src/tint/lang/glsl/ir/combined_texture_sampler_var.cc @@ -0,0 +1,56 @@ +// Copyright 2024 The Dawn & Tint Authors +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// 3. Neither the name of the copyright holder nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include "src/tint/lang/glsl/ir/combined_texture_sampler_var.h" + +#include + +#include "src/tint/lang/core/ir/clone_context.h" +#include "src/tint/lang/core/ir/module.h" +#include "src/tint/utils/ice/ice.h" + +TINT_INSTANTIATE_TYPEINFO(tint::glsl::ir::CombinedTextureSamplerVar); + +namespace tint::glsl::ir { + +CombinedTextureSamplerVar::CombinedTextureSamplerVar(Id id, + core::ir::InstructionResult* result, + tint::BindingPoint texture_bp, + tint::BindingPoint sampler_bp) + : Base(id, result), sampler_binding_point_(sampler_bp) { + SetBindingPoint(texture_bp.group, texture_bp.binding); +} + +CombinedTextureSamplerVar::~CombinedTextureSamplerVar() = default; + +CombinedTextureSamplerVar* CombinedTextureSamplerVar::Clone(core::ir::CloneContext& ctx) { + auto* new_result = ctx.Clone(Result(0)); + return ctx.ir.CreateInstruction(new_result, TextureBindingPoint(), + SamplerBindingPoint()); +} + +} // namespace tint::glsl::ir diff --git a/src/tint/lang/glsl/ir/combined_texture_sampler_var.h b/src/tint/lang/glsl/ir/combined_texture_sampler_var.h new file mode 100644 index 0000000000..1aa2552287 --- /dev/null +++ b/src/tint/lang/glsl/ir/combined_texture_sampler_var.h @@ -0,0 +1,75 @@ +// Copyright 2024 The Dawn & Tint Authors +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// 3. Neither the name of the copyright holder nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef SRC_TINT_LANG_GLSL_IR_COMBINED_TEXTURE_SAMPLER_VAR_H_ +#define SRC_TINT_LANG_GLSL_IR_COMBINED_TEXTURE_SAMPLER_VAR_H_ + +#include + +#include "src/tint/lang/core/ir/var.h" +#include "src/tint/utils/rtti/castable.h" + +namespace tint::glsl::ir { + +/// A combined texture sampler variable instruction in the IR. +class CombinedTextureSamplerVar final : public Castable { + public: + /// Constructor + /// @param id the instruction id + /// @param result the result value + /// @param texture_bp the texture binding point + /// @param sampler_bp the sampler binding point + CombinedTextureSamplerVar(Id id, + core::ir::InstructionResult* result, + tint::BindingPoint texture_bp, + tint::BindingPoint sampler_bp); + + ~CombinedTextureSamplerVar() override; + + /// @returns the texture binding point + tint::BindingPoint TextureBindingPoint() { + auto bp = BindingPoint(); + TINT_ASSERT(bp); + return *bp; + } + + /// @returns the sampler binding point + tint::BindingPoint SamplerBindingPoint() { return sampler_binding_point_; } + + /// @copydoc core::ir::Instruction::Clone() + CombinedTextureSamplerVar* Clone(core::ir::CloneContext& ctx) override; + + /// @returns the friendly name for the instruction + std::string FriendlyName() const override { return "combined_texture_sampler"; } + + private: + tint::BindingPoint sampler_binding_point_; +}; + +} // namespace tint::glsl::ir + +#endif // SRC_TINT_LANG_GLSL_IR_COMBINED_TEXTURE_SAMPLER_VAR_H_ diff --git a/src/tint/lang/glsl/ir/combined_texture_sampler_var_test.cc b/src/tint/lang/glsl/ir/combined_texture_sampler_var_test.cc new file mode 100644 index 0000000000..429d3c1c7b --- /dev/null +++ b/src/tint/lang/glsl/ir/combined_texture_sampler_var_test.cc @@ -0,0 +1,63 @@ +// Copyright 2024 The Dawn & Tint Authors +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// 3. Neither the name of the copyright holder nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include "src/tint/lang/glsl/ir/combined_texture_sampler_var.h" + +#include "gtest/gtest.h" +#include "src/tint/lang/core/ir/ir_helper_test.h" +#include "src/tint/lang/core/ir/validator.h" +#include "src/tint/lang/core/type/sampled_texture.h" + +using namespace tint::core::fluent_types; // NOLINT + +namespace tint::glsl::ir { +namespace { + +using namespace tint::core::number_suffixes; // NOLINT + // +using IR_GlslCombinedTextureSamplerTest = core::ir::IRTestHelper; + +TEST_F(IR_GlslCombinedTextureSamplerTest, Clone) { + BindingPoint texture_bp{1, 2}; + BindingPoint sampler_bp{3, 4}; + auto* type = ty.ptr( + ty.Get(core::type::TextureDimension::k2d, ty.f32())); + auto* var = mod.CreateInstruction(b.InstructionResult(type), + texture_bp, sampler_bp); + + auto* new_var = clone_ctx.Clone(var); + + EXPECT_NE(var, new_var); + EXPECT_NE(var->Result(0), new_var->Result(0)); + EXPECT_EQ(new_var->Result(0)->Type(), type); + + EXPECT_EQ(new_var->TextureBindingPoint(), texture_bp); + EXPECT_EQ(new_var->SamplerBindingPoint(), sampler_bp); +} + +} // namespace +} // namespace tint::glsl::ir diff --git a/src/tint/lang/glsl/writer/printer/BUILD.bazel b/src/tint/lang/glsl/writer/printer/BUILD.bazel index 07e317e815..a97e90d38e 100644 --- a/src/tint/lang/glsl/writer/printer/BUILD.bazel +++ b/src/tint/lang/glsl/writer/printer/BUILD.bazel @@ -54,6 +54,11 @@ cc_library( "//src/tint/lang/glsl", "//src/tint/lang/glsl/intrinsic", "//src/tint/lang/glsl/ir", + "//src/tint/lang/wgsl", + "//src/tint/lang/wgsl/ast", + "//src/tint/lang/wgsl/ast/transform", + "//src/tint/lang/wgsl/program", + "//src/tint/lang/wgsl/sem", "//src/tint/utils", "//src/tint/utils/containers", "//src/tint/utils/diagnostic", diff --git a/src/tint/lang/glsl/writer/printer/BUILD.cmake b/src/tint/lang/glsl/writer/printer/BUILD.cmake index 109b197b4a..3c8c058f95 100644 --- a/src/tint/lang/glsl/writer/printer/BUILD.cmake +++ b/src/tint/lang/glsl/writer/printer/BUILD.cmake @@ -55,6 +55,11 @@ tint_target_add_dependencies(tint_lang_glsl_writer_printer lib tint_lang_glsl tint_lang_glsl_intrinsic tint_lang_glsl_ir + tint_lang_wgsl + tint_lang_wgsl_ast + tint_lang_wgsl_ast_transform + tint_lang_wgsl_program + tint_lang_wgsl_sem tint_utils tint_utils_containers tint_utils_diagnostic diff --git a/src/tint/lang/glsl/writer/printer/BUILD.gn b/src/tint/lang/glsl/writer/printer/BUILD.gn index 9fe36b691b..4e006f4623 100644 --- a/src/tint/lang/glsl/writer/printer/BUILD.gn +++ b/src/tint/lang/glsl/writer/printer/BUILD.gn @@ -55,6 +55,11 @@ if (tint_build_glsl_writer) { "${tint_src_dir}/lang/glsl", "${tint_src_dir}/lang/glsl/intrinsic", "${tint_src_dir}/lang/glsl/ir", + "${tint_src_dir}/lang/wgsl", + "${tint_src_dir}/lang/wgsl/ast", + "${tint_src_dir}/lang/wgsl/ast/transform", + "${tint_src_dir}/lang/wgsl/program", + "${tint_src_dir}/lang/wgsl/sem", "${tint_src_dir}/utils", "${tint_src_dir}/utils/containers", "${tint_src_dir}/utils/diagnostic", diff --git a/src/tint/lang/glsl/writer/printer/printer.cc b/src/tint/lang/glsl/writer/printer/printer.cc index 8a8282432c..fa208c36a6 100644 --- a/src/tint/lang/glsl/writer/printer/printer.cc +++ b/src/tint/lang/glsl/writer/printer/printer.cc @@ -81,7 +81,9 @@ #include "src/tint/lang/core/type/vector.h" #include "src/tint/lang/core/type/void.h" #include "src/tint/lang/glsl/ir/builtin_call.h" +#include "src/tint/lang/glsl/ir/combined_texture_sampler_var.h" #include "src/tint/lang/glsl/ir/member_builtin_call.h" +#include "src/tint/lang/glsl/writer/common/options.h" #include "src/tint/lang/glsl/writer/common/printer_support.h" #include "src/tint/lang/glsl/writer/common/version.h" #include "src/tint/utils/containers/map.h" @@ -110,8 +112,8 @@ class Printer : public tint::TextGenerator { public: /// Constructor /// @param module the Tint IR module to generate - /// @param version the GLSL version information - Printer(core::ir::Module& module, const Version& version) : ir_(module), version_(version) {} + /// @param options the options to use for generating code + Printer(core::ir::Module& module, const Options& options) : ir_(module), options_(options) {} /// @returns the generated GLSL shader tint::Result Generate() { @@ -126,8 +128,9 @@ class Printer : public tint::TextGenerator { TINT_SCOPED_ASSIGNMENT(current_buffer_, &header_buffer_); auto out = Line(); - out << "#version " << version_.major_version << version_.minor_version << "0"; - if (version_.IsES()) { + out << "#version " << options_.version.major_version << options_.version.minor_version + << "0"; + if (options_.version.IsES()) { out << " es"; } } @@ -169,7 +172,7 @@ class Printer : public tint::TextGenerator { Output result_; - const Version& version_; + const Options& options_; /// The buffer holding header text TextBuffer header_buffer_; @@ -845,7 +848,7 @@ class Printer : public tint::TextGenerator { out << "writeonly "; break; case core::Access::kReadWrite: { - if (version_.IsES()) { + if (options_.version.IsES()) { // ESSL 3.1 SPEC (chapter 4.9, Memory Access Qualifiers): // Except for image variables qualified with the format qualifiers r32f, // r32i, and r32ui, image variables must specify either memory qualifier @@ -1037,6 +1040,18 @@ class Printer : public tint::TextGenerator { out << " "; } + // If this is a combined texture sampler variable, check the provided map to see if we need + // to give it a specific name. + if (auto* combined_texture_sampler = var->As()) { + binding::CombinedTextureSamplerPair key{ + combined_texture_sampler->TextureBindingPoint(), + combined_texture_sampler->SamplerBindingPoint()}; + auto itr = options_.bindings.sampler_texture_to_name.find(key); + if (itr != options_.bindings.sampler_texture_to_name.end()) { + names_.Add(var->Result(0), itr->second); + } + } + EmitVar(out, var); } @@ -1051,8 +1066,9 @@ class Printer : public tint::TextGenerator { auto addrspace = var->Result(0)->Type()->As()->AddressSpace(); if (attrs.builtin.has_value()) { - if (version_.IsES() && (attrs.builtin == tint::core::BuiltinValue::kSampleIndex || - attrs.builtin == tint::core::BuiltinValue::kSampleMask)) { + if (options_.version.IsES() && + (attrs.builtin == tint::core::BuiltinValue::kSampleIndex || + attrs.builtin == tint::core::BuiltinValue::kSampleMask)) { EmitExtension(kOESSampleVariables); } @@ -1563,13 +1579,13 @@ class Printer : public tint::TextGenerator { break; case core::BuiltinFn::kDpdxCoarse: out << "dFdx"; - if (version_.IsDesktop()) { + if (options_.version.IsDesktop()) { out << "Coarse"; } break; case core::BuiltinFn::kDpdxFine: out << "dFdx"; - if (version_.IsDesktop()) { + if (options_.version.IsDesktop()) { out << "Fine"; } break; @@ -1578,13 +1594,13 @@ class Printer : public tint::TextGenerator { break; case core::BuiltinFn::kDpdyCoarse: out << "dFdy"; - if (version_.IsDesktop()) { + if (options_.version.IsDesktop()) { out << "Coarse"; } break; case core::BuiltinFn::kDpdyFine: out << "dFdy"; - if (version_.IsDesktop()) { + if (options_.version.IsDesktop()) { out << "Fine"; } break; @@ -1784,8 +1800,8 @@ class Printer : public tint::TextGenerator { } // namespace -Result Print(core::ir::Module& module, const Version& version) { - return Printer{module, version}.Generate(); +Result Print(core::ir::Module& module, const Options& options) { + return Printer{module, options}.Generate(); } } // namespace tint::glsl::writer diff --git a/src/tint/lang/glsl/writer/printer/printer.h b/src/tint/lang/glsl/writer/printer/printer.h index aaeccf70c9..7114424b23 100644 --- a/src/tint/lang/glsl/writer/printer/printer.h +++ b/src/tint/lang/glsl/writer/printer/printer.h @@ -36,15 +36,15 @@ namespace tint::core::ir { class Module; } // namespace tint::core::ir namespace tint::glsl::writer { -struct Version; +struct Options; } // namespace tint::glsl::writer namespace tint::glsl::writer { /// @returns the generated GLSL shader on success, or failure /// @param module the Tint IR module to generate -/// @param version the GLSL version information -Result Print(core::ir::Module& module, const Version& version); +/// @param options the options to use +Result Print(core::ir::Module& module, const Options& options); } // namespace tint::glsl::writer diff --git a/src/tint/lang/glsl/writer/raise/raise.cc b/src/tint/lang/glsl/writer/raise/raise.cc index ae6283d740..d94ebfa526 100644 --- a/src/tint/lang/glsl/writer/raise/raise.cc +++ b/src/tint/lang/glsl/writer/raise/raise.cc @@ -179,7 +179,6 @@ Result Raise(core::ir::Module& module, const Options& options) { { // Must come after DirectVariableAccess raise::TexturePolyfillConfig tex_config; - tex_config.sampler_texture_to_name = options.bindings.sampler_texture_to_name; tex_config.placeholder_sampler_bind_point = options.bindings.placeholder_sampler_bind_point; tex_config.texture_builtins_from_uniform = options.bindings.texture_builtins_from_uniform; RUN_TRANSFORM(raise::TexturePolyfill, module, tex_config); diff --git a/src/tint/lang/glsl/writer/raise/texture_polyfill.cc b/src/tint/lang/glsl/writer/raise/texture_polyfill.cc index 83118cfb5d..baf355d606 100644 --- a/src/tint/lang/glsl/writer/raise/texture_polyfill.cc +++ b/src/tint/lang/glsl/writer/raise/texture_polyfill.cc @@ -41,6 +41,7 @@ #include "src/tint/lang/core/type/sampled_texture.h" #include "src/tint/lang/core/type/storage_texture.h" #include "src/tint/lang/glsl/ir/builtin_call.h" +#include "src/tint/lang/glsl/ir/combined_texture_sampler_var.h" #include "src/tint/lang/glsl/ir/member_builtin_call.h" namespace tint::glsl::writer::raise { @@ -269,32 +270,29 @@ struct State { core::ir::Var* tex, core::ir::Var* sampler, const core::type::Pointer* tex_ty) { - std::string name; - auto it = (cfg.sampler_texture_to_name.find(key)); - if (it != cfg.sampler_texture_to_name.end()) { - name = it->second; + // Create a combined texture sampler variable and insert it into the root block. + auto* result = b.InstructionResult(tex_ty); + auto* var = ir.CreateInstruction(result, key.texture, + key.sampler); + ir.root_block->Append(var); + + // Set the variable name based on the original texture and sampler names if provided. + StringStream name; + if (auto texture_name = ir.NameOf(tex)) { + name << texture_name.NameView(); } else { - name = ir.NameOf(tex).Name(); - if (name.empty()) { - name = "t"; - } - - if (sampler) { - auto sampler_name = ir.NameOf(sampler).Name(); - if (sampler_name.empty()) { - sampler_name = "s"; - } - name += "_" + sampler_name; - } - if (name.empty()) { - name = "v"; + name << "t"; + } + if (sampler) { + name << "_"; + if (auto sampler_name = ir.NameOf(sampler)) { + name << sampler_name.NameView(); + } else { + name << "s"; } } + ir.SetName(var, name.str()); - core::ir::Var* var = nullptr; - // We may already be inside an insert block, so make a new insert block instead of - // appending directly to the root block. - b.Append(ir.root_block, [&] { var = b.Var(name, tex_ty); }); return var; } diff --git a/src/tint/lang/glsl/writer/raise/texture_polyfill.h b/src/tint/lang/glsl/writer/raise/texture_polyfill.h index 63ed0dd2be..a52a7273e6 100644 --- a/src/tint/lang/glsl/writer/raise/texture_polyfill.h +++ b/src/tint/lang/glsl/writer/raise/texture_polyfill.h @@ -39,10 +39,6 @@ class Module; namespace tint::glsl::writer::raise { struct TexturePolyfillConfig { - /// A map of SamplerTexturePair to combined sampler names for the - /// CombineSamplers transform - CombinedTextureSamplerInfo sampler_texture_to_name; - /// The binding point to use for placeholder samplers. BindingPoint placeholder_sampler_bind_point; @@ -53,7 +49,6 @@ struct TexturePolyfillConfig { /// Reflection for this class TINT_REFLECT(TexturePolyfillConfig, - sampler_texture_to_name, placeholder_sampler_bind_point, texture_builtins_from_uniform); }; diff --git a/src/tint/lang/glsl/writer/raise/texture_polyfill_test.cc b/src/tint/lang/glsl/writer/raise/texture_polyfill_test.cc index 4ebcdb7f46..37bfe556c4 100644 --- a/src/tint/lang/glsl/writer/raise/texture_polyfill_test.cc +++ b/src/tint/lang/glsl/writer/raise/texture_polyfill_test.cc @@ -78,7 +78,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureDimensions_1d) { auto* expect = R"( $B1: { # root - %v:ptr, read_write> = var + %v:ptr, read_write> = combined_texture_sampler @binding_point(0, 0) } %foo = func():u32 { @@ -130,7 +130,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureDimensions_2d_WithoutLod) { auto* expect = R"( $B1: { # root - %v:ptr, read_write> = var + %v:ptr, read_write> = combined_texture_sampler @binding_point(0, 0) } %foo = func():vec2 { @@ -181,7 +181,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureDimensions_2d_WithU32Lod) { auto* expect = R"( $B1: { # root - %v:ptr, read_write> = var + %v:ptr, read_write> = combined_texture_sampler @binding_point(0, 0) } %foo = func():vec2 { @@ -233,7 +233,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureDimensions_2dArray) { auto* expect = R"( $B1: { # root - %v:ptr, read_write> = var + %v:ptr, read_write> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { @@ -338,7 +338,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureDimensions_DepthMultisampled) { auto* expect = R"( $B1: { # root - %v:ptr = var + %v:ptr = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { @@ -391,7 +391,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureNumLayers_2DArray) { auto* expect = R"( $B1: { # root - %v:ptr, read_write> = var + %v:ptr, read_write> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { @@ -444,7 +444,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureNumLayers_Depth2DArray) { auto* expect = R"( $B1: { # root - %v:ptr, read_write> = var + %v:ptr, read_write> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { @@ -498,7 +498,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureNumLayers_CubeArray) { auto* expect = R"( $B1: { # root - %v:ptr, read_write> = var + %v:ptr, read_write> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { @@ -551,7 +551,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureNumLayers_DepthCubeArray) { auto* expect = R"( $B1: { # root - %v:ptr, read_write> = var + %v:ptr, read_write> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { @@ -660,7 +660,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureLoad_1DF32) { auto* expect = R"( $B1: { # root - %v:ptr, read_write> = var + %v:ptr, read_write> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { @@ -715,7 +715,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureLoad_2DLevelI32) { auto* expect = R"( $B1: { # root - %v:ptr, read_write> = var + %v:ptr, read_write> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { @@ -769,7 +769,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureLoad_3DLevelU32) { auto* expect = R"( $B1: { # root - %v:ptr, read_write> = var + %v:ptr, read_write> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { @@ -825,7 +825,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureLoad_Multisampled2DI32) { auto* expect = R"( $B1: { # root - %v:ptr, read_write> = var + %v:ptr, read_write> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { @@ -1204,12 +1204,12 @@ TEST_F(GlslWriter_TexturePolyfillTest, CombineSamplers_GlobalTextureNoSampler) { auto* expect = R"( $B1: { # root - %my_tex:ptr, read_write> = var + %t:ptr, read_write> = combined_texture_sampler @binding_point(0, 0) } %foo = func():vec2 { $B2: { - %3:texture_2d = load %my_tex + %3:texture_2d = load %t %4:vec2 = glsl.textureSize %3, 0i %5:vec2 = bitcast %4 ret %5 @@ -1221,12 +1221,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, CombineSamplers_GlobalTextureNoSampler) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {2, 2}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -1277,7 +1271,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureGatherCompare_Depth2d) { auto* expect = R"( $B1: { # root - %t_s:ptr = var + %t_s:ptr = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { @@ -1295,12 +1289,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureGatherCompare_Depth2d) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {2, 2}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -1353,7 +1341,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureGatherCompare_Depth2dOffset) { auto* expect = R"( $B1: { # root - %t_s:ptr = var + %t_s:ptr = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { @@ -1372,12 +1360,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureGatherCompare_Depth2dOffset) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {2, 2}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -1429,7 +1411,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureGatherCompare_DepthCubeArray) { auto* expect = R"( $B1: { # root - %t_s:ptr = var + %t_s:ptr = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { @@ -1449,12 +1431,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureGatherCompare_DepthCubeArray) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {2, 2}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -1508,7 +1484,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureGatherCompare_Depth2dArrayOffset) auto* expect = R"( $B1: { # root - %t_s:ptr = var + %t_s:ptr = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { @@ -1529,12 +1505,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureGatherCompare_Depth2dArrayOffset) TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {2, 2}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -1583,7 +1553,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureGather_Alpha) { auto* expect = R"( $B1: { # root - %t_s:ptr, read> = var + %t_s:ptr, read> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { @@ -1602,12 +1572,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureGather_Alpha) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {2, 2}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -1656,7 +1620,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureGather_RedOffset) { auto* expect = R"( $B1: { # root - %t_s:ptr, read> = var + %t_s:ptr, read> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { @@ -1675,12 +1639,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureGather_RedOffset) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {2, 2}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -1730,7 +1688,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureGather_GreenArray) { auto* expect = R"( $B1: { # root - %t_s:ptr, read> = var + %t_s:ptr, read> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { @@ -1751,12 +1709,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureGather_GreenArray) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {2, 2}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -1808,7 +1760,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureGather_BlueArrayOffset) { auto* expect = R"( $B1: { # root - %t_s:ptr, read> = var + %t_s:ptr, read> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { @@ -1829,12 +1781,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureGather_BlueArrayOffset) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {2, 2}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -1883,7 +1829,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureGather_Depth) { auto* expect = R"( $B1: { # root - %t_s:ptr = var + %t_s:ptr = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { @@ -1901,12 +1847,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureGather_Depth) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {2, 2}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -1955,7 +1895,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureGather_DepthOffset) { auto* expect = R"( $B1: { # root - %t_s:ptr = var + %t_s:ptr = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { @@ -1973,12 +1913,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureGather_DepthOffset) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {2, 2}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -2028,7 +1962,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureGather_DepthArray) { auto* expect = R"( $B1: { # root - %t_s:ptr = var + %t_s:ptr = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { @@ -2048,12 +1982,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureGather_DepthArray) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {2, 2}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -2105,7 +2033,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureGather_DepthArrayOffset) { auto* expect = R"( $B1: { # root - %t_s:ptr = var + %t_s:ptr = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { @@ -2125,12 +2053,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureGather_DepthArrayOffset) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {2, 2}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -2178,13 +2100,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSample_1d) { auto* expect = R"( $B1: { # root - %my_tex:ptr, read> = var + %t_s:ptr, read> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec2 = construct 1.0f, 0.5f - %4:texture_2d = load %my_tex + %4:texture_2d = load %t_s %5:vec4 = glsl.texture %4, %3 %x:vec4 = let %5 ret @@ -2196,12 +2118,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSample_1d) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -2250,13 +2166,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSample_2d) { auto* expect = R"( $B1: { # root - %my_tex:ptr, read> = var + %t_s:ptr, read> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec2 = construct 1.0f, 2.0f - %4:texture_2d = load %my_tex + %4:texture_2d = load %t_s %5:vec4 = glsl.texture %4, %3 %x:vec4 = let %5 ret @@ -2268,12 +2184,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSample_2d) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -2323,13 +2233,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSample_2d_Offset) { auto* expect = R"( $B1: { # root - %my_tex:ptr, read> = var + %t_s:ptr, read> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec2 = construct 1.0f, 2.0f - %4:texture_2d = load %my_tex + %4:texture_2d = load %t_s %5:vec4 = glsl.textureOffset %4, %3, vec2(4i, 5i) %x:vec4 = let %5 ret @@ -2341,12 +2251,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSample_2d_Offset) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -2396,13 +2300,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSample_2d_Array) { auto* expect = R"( $B1: { # root - %my_tex:ptr, read> = var + %t_s:ptr, read> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec2 = construct 1.0f, 2.0f - %4:texture_2d_array = load %my_tex + %4:texture_2d_array = load %t_s %5:f32 = convert 4u %6:vec3 = construct %3, %5 %7:vec4 = glsl.texture %4, %6 @@ -2416,12 +2320,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSample_2d_Array) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -2473,13 +2371,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSample_2d_Array_Offset) { auto* expect = R"( $B1: { # root - %my_tex:ptr, read> = var + %t_s:ptr, read> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec2 = construct 1.0f, 2.0f - %4:texture_2d_array = load %my_tex + %4:texture_2d_array = load %t_s %5:f32 = convert 4u %6:vec3 = construct %3, %5 %7:vec4 = glsl.textureOffset %4, %6, vec2(4i, 5i) @@ -2493,12 +2391,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSample_2d_Array_Offset) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -2547,13 +2439,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSample_3d) { auto* expect = R"( $B1: { # root - %my_tex:ptr, read> = var + %t_s:ptr, read> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec3 = construct 1.0f, 2.0f, 3.0f - %4:texture_3d = load %my_tex + %4:texture_3d = load %t_s %5:vec4 = glsl.texture %4, %3 %x:vec4 = let %5 ret @@ -2565,12 +2457,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSample_3d) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -2620,13 +2506,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSample_3d_Offset) { auto* expect = R"( $B1: { # root - %my_tex:ptr, read> = var + %t_s:ptr, read> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec3 = construct 1.0f, 2.0f, 3.0f - %4:texture_3d = load %my_tex + %4:texture_3d = load %t_s %5:vec4 = glsl.textureOffset %4, %3, vec3(4i, 5i, 6i) %x:vec4 = let %5 ret @@ -2638,12 +2524,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSample_3d_Offset) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -2692,13 +2572,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSample_Cube) { auto* expect = R"( $B1: { # root - %my_tex:ptr, read> = var + %t_s:ptr, read> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec3 = construct 1.0f, 2.0f, 3.0f - %4:texture_cube = load %my_tex + %4:texture_cube = load %t_s %5:vec4 = glsl.texture %4, %3 %x:vec4 = let %5 ret @@ -2710,12 +2590,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSample_Cube) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -2765,13 +2639,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSample_Cube_Array) { auto* expect = R"( $B1: { # root - %my_tex:ptr, read> = var + %t_s:ptr, read> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec3 = construct 1.0f, 2.0f, 3.0f - %4:texture_cube_array = load %my_tex + %4:texture_cube_array = load %t_s %5:f32 = convert 4u %6:vec4 = construct %3, %5 %7:vec4 = glsl.texture %4, %6 @@ -2785,12 +2659,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSample_Cube_Array) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -2839,13 +2707,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSample_Depth2d) { auto* expect = R"( $B1: { # root - %my_tex:ptr = var + %t_s:ptr = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec2 = construct 1.0f, 2.0f - %4:texture_depth_2d = load %my_tex + %4:texture_depth_2d = load %t_s %5:vec3 = construct %3, 0.0f %6:f32 = glsl.texture %4, %5 %x:f32 = let %6 @@ -2858,12 +2726,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSample_Depth2d) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -2913,13 +2775,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSample_Depth2d_Offset) { auto* expect = R"( $B1: { # root - %my_tex:ptr = var + %t_s:ptr = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec2 = construct 1.0f, 2.0f - %4:texture_depth_2d = load %my_tex + %4:texture_depth_2d = load %t_s %5:vec3 = construct %3, 0.0f %6:f32 = glsl.textureOffset %4, %5, vec2(4i, 5i) %x:f32 = let %6 @@ -2932,12 +2794,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSample_Depth2d_Offset) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -2987,13 +2843,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSample_Depth2d_Array) { auto* expect = R"( $B1: { # root - %my_tex:ptr = var + %t_s:ptr = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec2 = construct 1.0f, 2.0f - %4:texture_depth_2d_array = load %my_tex + %4:texture_depth_2d_array = load %t_s %5:f32 = convert 4u %6:vec4 = construct %3, %5, 0.0f %7:f32 = glsl.texture %4, %6 @@ -3007,12 +2863,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSample_Depth2d_Array) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -3063,13 +2913,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSample_Depth2d_Array_Offset) { auto* expect = R"( $B1: { # root - %my_tex:ptr = var + %t_s:ptr = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec2 = construct 1.0f, 2.0f - %4:texture_depth_2d_array = load %my_tex + %4:texture_depth_2d_array = load %t_s %5:f32 = convert 4u %6:vec4 = construct %3, %5, 0.0f %7:vec2 = dpdx %3 @@ -3085,12 +2935,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSample_Depth2d_Array_Offset) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -3140,13 +2984,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSample_DepthCube_Array) { auto* expect = R"( $B1: { # root - %my_tex:ptr = var + %t_s:ptr = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec3 = construct 1.0f, 2.0f, 3.0f - %4:texture_depth_cube_array = load %my_tex + %4:texture_depth_cube_array = load %t_s %5:f32 = convert 4u %6:vec4 = construct %3, %5 %7:f32 = glsl.texture %4, %6, 0.0f @@ -3160,12 +3004,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSample_DepthCube_Array) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -3214,13 +3052,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleBias_2d) { auto* expect = R"( $B1: { # root - %my_tex:ptr, read> = var + %t_s:ptr, read> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec2 = construct 1.0f, 2.0f - %4:texture_2d = load %my_tex + %4:texture_2d = load %t_s %5:vec4 = glsl.texture %4, %3, 3.0f %x:vec4 = let %5 ret @@ -3232,12 +3070,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleBias_2d) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -3288,13 +3120,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleBias_2d_Offset) { auto* expect = R"( $B1: { # root - %my_tex:ptr, read> = var + %t_s:ptr, read> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec2 = construct 1.0f, 2.0f - %4:texture_2d = load %my_tex + %4:texture_2d = load %t_s %5:vec4 = glsl.textureOffset %4, %3, vec2(4i, 5i), 3.0f %x:vec4 = let %5 ret @@ -3306,12 +3138,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleBias_2d_Offset) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -3362,13 +3188,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleBias_2d_Array) { auto* expect = R"( $B1: { # root - %my_tex:ptr, read> = var + %t_s:ptr, read> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec2 = construct 1.0f, 2.0f - %4:texture_2d_array = load %my_tex + %4:texture_2d_array = load %t_s %5:f32 = convert 4u %6:vec3 = construct %3, %5 %7:vec4 = glsl.texture %4, %6, 3.0f @@ -3382,12 +3208,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleBias_2d_Array) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -3439,13 +3259,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleBias_2d_Array_Offset) { auto* expect = R"( $B1: { # root - %my_tex:ptr, read> = var + %t_s:ptr, read> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec2 = construct 1.0f, 2.0f - %4:texture_2d_array = load %my_tex + %4:texture_2d_array = load %t_s %5:f32 = convert 4u %6:vec3 = construct %3, %5 %7:vec4 = glsl.textureOffset %4, %6, vec2(4i, 5i), 3.0f @@ -3459,12 +3279,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleBias_2d_Array_Offset) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -3513,13 +3327,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleBias_3d) { auto* expect = R"( $B1: { # root - %my_tex:ptr, read> = var + %t_s:ptr, read> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec3 = construct 1.0f, 2.0f, 3.0f - %4:texture_3d = load %my_tex + %4:texture_3d = load %t_s %5:vec4 = glsl.texture %4, %3, 3.0f %x:vec4 = let %5 ret @@ -3531,12 +3345,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleBias_3d) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -3587,13 +3395,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleBias_3d_Offset) { auto* expect = R"( $B1: { # root - %my_tex:ptr, read> = var + %t_s:ptr, read> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec3 = construct 1.0f, 2.0f, 3.0f - %4:texture_3d = load %my_tex + %4:texture_3d = load %t_s %5:vec4 = glsl.textureOffset %4, %3, vec3(4i, 5i, 6i), 3.0f %x:vec4 = let %5 ret @@ -3605,12 +3413,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleBias_3d_Offset) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -3659,13 +3461,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleBias_Cube) { auto* expect = R"( $B1: { # root - %my_tex:ptr, read> = var + %t_s:ptr, read> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec3 = construct 1.0f, 2.0f, 3.0f - %4:texture_cube = load %my_tex + %4:texture_cube = load %t_s %5:vec4 = glsl.texture %4, %3, 3.0f %x:vec4 = let %5 ret @@ -3677,12 +3479,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleBias_Cube) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -3733,13 +3529,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleBias_Cube_Array) { auto* expect = R"( $B1: { # root - %my_tex:ptr, read> = var + %t_s:ptr, read> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec3 = construct 1.0f, 2.0f, 3.0f - %4:texture_cube_array = load %my_tex + %4:texture_cube_array = load %t_s %5:f32 = convert 4u %6:vec4 = construct %3, %5 %7:vec4 = glsl.texture %4, %6, 3.0f @@ -3753,12 +3549,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleBias_Cube_Array) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -3807,13 +3597,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleLevel_2d) { auto* expect = R"( $B1: { # root - %my_tex:ptr, read> = var + %t_s:ptr, read> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec2 = construct 1.0f, 2.0f - %4:texture_2d = load %my_tex + %4:texture_2d = load %t_s %5:f32 = convert 3.0f %6:vec4 = glsl.textureLod %4, %3, %5 %x:vec4 = let %6 @@ -3826,12 +3616,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleLevel_2d) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -3882,13 +3666,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleLevel_2d_Offset) { auto* expect = R"( $B1: { # root - %my_tex:ptr, read> = var + %t_s:ptr, read> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec2 = construct 1.0f, 2.0f - %4:texture_2d = load %my_tex + %4:texture_2d = load %t_s %5:f32 = convert 3.0f %6:vec4 = glsl.textureLodOffset %4, %3, %5, vec2(4i, 5i) %x:vec4 = let %6 @@ -3901,12 +3685,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleLevel_2d_Offset) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -3957,13 +3735,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleLevel_2d_Array) { auto* expect = R"( $B1: { # root - %my_tex:ptr, read> = var + %t_s:ptr, read> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec2 = construct 1.0f, 2.0f - %4:texture_2d_array = load %my_tex + %4:texture_2d_array = load %t_s %5:f32 = convert 4u %6:vec3 = construct %3, %5 %7:f32 = convert 3.0f @@ -3978,12 +3756,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleLevel_2d_Array) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -4035,13 +3807,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleLevel_2d_Array_Offset) { auto* expect = R"( $B1: { # root - %my_tex:ptr, read> = var + %t_s:ptr, read> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec2 = construct 1.0f, 2.0f - %4:texture_2d_array = load %my_tex + %4:texture_2d_array = load %t_s %5:f32 = convert 4u %6:vec3 = construct %3, %5 %7:f32 = convert 3.0f @@ -4056,12 +3828,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleLevel_2d_Array_Offset) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -4110,13 +3876,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleLevel_3d) { auto* expect = R"( $B1: { # root - %my_tex:ptr, read> = var + %t_s:ptr, read> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec3 = construct 1.0f, 2.0f, 3.0f - %4:texture_3d = load %my_tex + %4:texture_3d = load %t_s %5:f32 = convert 3.0f %6:vec4 = glsl.textureLod %4, %3, %5 %x:vec4 = let %6 @@ -4129,12 +3895,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleLevel_3d) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -4185,13 +3945,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleLevel_3d_Offset) { auto* expect = R"( $B1: { # root - %my_tex:ptr, read> = var + %t_s:ptr, read> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec3 = construct 1.0f, 2.0f, 3.0f - %4:texture_3d = load %my_tex + %4:texture_3d = load %t_s %5:f32 = convert 3.0f %6:vec4 = glsl.textureLodOffset %4, %3, %5, vec3(4i, 5i, 6i) %x:vec4 = let %6 @@ -4204,12 +3964,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleLevel_3d_Offset) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -4258,13 +4012,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleLevel_Cube) { auto* expect = R"( $B1: { # root - %my_tex:ptr, read> = var + %t_s:ptr, read> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec3 = construct 1.0f, 2.0f, 3.0f - %4:texture_cube = load %my_tex + %4:texture_cube = load %t_s %5:f32 = convert 3.0f %6:vec4 = glsl.textureLod %4, %3, %5 %x:vec4 = let %6 @@ -4277,12 +4031,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleLevel_Cube) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -4333,13 +4081,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleLevel_Cube_Array) { auto* expect = R"( $B1: { # root - %my_tex:ptr, read> = var + %t_s:ptr, read> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec3 = construct 1.0f, 2.0f, 3.0f - %4:texture_cube_array = load %my_tex + %4:texture_cube_array = load %t_s %5:f32 = convert 4u %6:vec4 = construct %3, %5 %7:f32 = convert 3.0f @@ -4354,12 +4102,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleLevel_Cube_Array) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -4408,13 +4150,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleLevel_Depth2d) { auto* expect = R"( $B1: { # root - %my_tex:ptr = var + %t_s:ptr = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec2 = construct 1.0f, 2.0f - %4:texture_depth_2d = load %my_tex + %4:texture_depth_2d = load %t_s %5:vec3 = construct %3, 0.0f %6:f32 = convert 3i %7:f32 = glsl.textureLod %4, %5, %6 @@ -4428,12 +4170,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleLevel_Depth2d) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -4483,13 +4219,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleLevel_Depth2d_Offset) { auto* expect = R"( $B1: { # root - %my_tex:ptr = var + %t_s:ptr = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec2 = construct 1.0f, 2.0f - %4:texture_depth_2d = load %my_tex + %4:texture_depth_2d = load %t_s %5:vec3 = construct %3, 0.0f %6:f32 = convert 3u %7:f32 = glsl.textureLodOffset %4, %5, %6, vec2(4i, 5i) @@ -4503,12 +4239,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleLevel_Depth2d_Offset) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -4558,13 +4288,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleLevel_Depth2d_Array) { auto* expect = R"( $B1: { # root - %my_tex:ptr = var + %t_s:ptr = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec2 = construct 1.0f, 2.0f - %4:texture_depth_2d_array = load %my_tex + %4:texture_depth_2d_array = load %t_s %5:f32 = convert 4u %6:vec4 = construct %3, %5, 0.0f %7:f32 = convert 3i @@ -4579,12 +4309,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleLevel_Depth2d_Array) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -4636,13 +4360,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleLevel_Depth2d_Array_Offset) auto* expect = R"( $B1: { # root - %my_tex:ptr = var + %t_s:ptr = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec2 = construct 1.0f, 2.0f - %4:texture_depth_2d_array = load %my_tex + %4:texture_depth_2d_array = load %t_s %5:f32 = convert 4u %6:vec4 = construct %3, %5, 0.0f %7:f32 = convert 3u @@ -4657,12 +4381,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleLevel_Depth2d_Array_Offset) TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -4712,13 +4430,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleLevel_DepthCube_Array) { auto* expect = R"( $B1: { # root - %my_tex:ptr = var + %t_s:ptr = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec3 = construct 1.0f, 2.0f, 3i - %4:texture_depth_cube_array = load %my_tex + %4:texture_depth_cube_array = load %t_s %5:f32 = convert 4u %6:vec4 = construct %3, %5 %7:f32 = convert 3i @@ -4733,12 +4451,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleLevel_DepthCube_Array) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -4791,7 +4503,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleGrad_2d) { auto* expect = R"( $B1: { # root - %my_tex:ptr, read> = var + %t_s:ptr, read> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { @@ -4799,7 +4511,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleGrad_2d) { %3:vec2 = construct 1.0f, 2.0f %4:vec2 = construct 3.0f, 4.0f %5:vec2 = construct 6.0f, 7.0f - %6:texture_2d = load %my_tex + %6:texture_2d = load %t_s %7:vec4 = glsl.textureGrad %6, %3, %4, %5 %x:vec4 = let %7 ret @@ -4811,12 +4523,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleGrad_2d) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -4871,7 +4577,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleGrad_2d_Offset) { auto* expect = R"( $B1: { # root - %my_tex:ptr, read> = var + %t_s:ptr, read> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { @@ -4879,7 +4585,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleGrad_2d_Offset) { %3:vec2 = construct 1.0f, 2.0f %4:vec2 = construct 3.0f, 4.0f %5:vec2 = construct 6.0f, 7.0f - %6:texture_2d = load %my_tex + %6:texture_2d = load %t_s %7:vec4 = glsl.textureGradOffset %6, %3, %4, %5, vec2(4i, 5i) %x:vec4 = let %7 ret @@ -4891,12 +4597,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleGrad_2d_Offset) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -4951,7 +4651,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleGrad_2d_Array) { auto* expect = R"( $B1: { # root - %my_tex:ptr, read> = var + %t_s:ptr, read> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { @@ -4959,7 +4659,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleGrad_2d_Array) { %3:vec2 = construct 1.0f, 2.0f %4:vec2 = construct 3.0f, 4.0f %5:vec2 = construct 6.0f, 7.0f - %6:texture_2d_array = load %my_tex + %6:texture_2d_array = load %t_s %7:f32 = convert 4u %8:vec3 = construct %3, %7 %9:vec4 = glsl.textureGrad %6, %8, %4, %5 @@ -4973,12 +4673,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleGrad_2d_Array) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -5034,7 +4728,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleGrad_2d_Array_Offset) { auto* expect = R"( $B1: { # root - %my_tex:ptr, read> = var + %t_s:ptr, read> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { @@ -5042,7 +4736,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleGrad_2d_Array_Offset) { %3:vec2 = construct 1.0f, 2.0f %4:vec2 = construct 3.0f, 4.0f %5:vec2 = construct 6.0f, 7.0f - %6:texture_2d_array = load %my_tex + %6:texture_2d_array = load %t_s %7:f32 = convert 4u %8:vec3 = construct %3, %7 %9:vec4 = glsl.textureGradOffset %6, %8, %4, %5, vec2(4i, 5i) @@ -5056,12 +4750,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleGrad_2d_Array_Offset) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -5114,7 +4802,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleGrad_3d) { auto* expect = R"( $B1: { # root - %my_tex:ptr, read> = var + %t_s:ptr, read> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { @@ -5122,7 +4810,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleGrad_3d) { %3:vec3 = construct 1.0f, 2.0f, 3.0f %4:vec3 = construct 3.0f, 4.0f, 5.0f %5:vec3 = construct 6.0f, 7.0f, 8.0f - %6:texture_3d = load %my_tex + %6:texture_3d = load %t_s %7:vec4 = glsl.textureGrad %6, %3, %4, %5 %x:vec4 = let %7 ret @@ -5134,12 +4822,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleGrad_3d) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -5194,7 +4876,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleGrad_3d_Offset) { auto* expect = R"( $B1: { # root - %my_tex:ptr, read> = var + %t_s:ptr, read> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { @@ -5202,7 +4884,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleGrad_3d_Offset) { %3:vec3 = construct 1.0f, 2.0f, 3.0f %4:vec3 = construct 3.0f, 4.0f, 5.0f %5:vec3 = construct 6.0f, 7.0f, 8.0f - %6:texture_3d = load %my_tex + %6:texture_3d = load %t_s %7:vec4 = glsl.textureGradOffset %6, %3, %4, %5, vec3(4i, 5i, 6i) %x:vec4 = let %7 ret @@ -5214,12 +4896,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleGrad_3d_Offset) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -5272,7 +4948,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleGrad_Cube) { auto* expect = R"( $B1: { # root - %my_tex:ptr, read> = var + %t_s:ptr, read> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { @@ -5280,7 +4956,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleGrad_Cube) { %3:vec3 = construct 1.0f, 2.0f, 3.0f %4:vec3 = construct 3.0f, 4.0f, 5.0f %5:vec3 = construct 6.0f, 7.0f, 8.0f - %6:texture_cube = load %my_tex + %6:texture_cube = load %t_s %7:vec4 = glsl.textureGrad %6, %3, %4, %5 %x:vec4 = let %7 ret @@ -5292,12 +4968,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleGrad_Cube) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -5352,7 +5022,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleGrad_Cube_Array) { auto* expect = R"( $B1: { # root - %my_tex:ptr, read> = var + %t_s:ptr, read> = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { @@ -5360,7 +5030,7 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleGrad_Cube_Array) { %3:vec3 = construct 1.0f, 2.0f, 3.0f %4:vec3 = construct 3.0f, 4.0f, 5.0f %5:vec3 = construct 6.0f, 7.0f, 8.0f - %6:texture_cube_array = load %my_tex + %6:texture_cube_array = load %t_s %7:f32 = convert 4u %8:vec4 = construct %3, %7 %9:vec4 = glsl.textureGrad %6, %8, %4, %5 @@ -5374,12 +5044,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleGrad_Cube_Array) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -5428,13 +5092,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleCompare_2d) { auto* expect = R"( $B1: { # root - %my_tex:ptr = var + %t_s:ptr = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec2 = construct 1.0f, 2.0f - %4:texture_depth_2d = load %my_tex + %4:texture_depth_2d = load %t_s %5:vec3 = construct %3, 3.0f %6:f32 = glsl.texture %4, %5 %x:f32 = let %6 @@ -5447,12 +5111,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleCompare_2d) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -5502,13 +5160,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleCompare_2d_Offset) { auto* expect = R"( $B1: { # root - %my_tex:ptr = var + %t_s:ptr = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec2 = construct 1.0f, 2.0f - %4:texture_depth_2d = load %my_tex + %4:texture_depth_2d = load %t_s %5:vec3 = construct %3, 3.0f %6:f32 = glsl.textureOffset %4, %5, vec2(4i, 5i) %x:f32 = let %6 @@ -5521,12 +5179,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleCompare_2d_Offset) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -5577,13 +5229,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleCompare_2d_Array) { auto* expect = R"( $B1: { # root - %my_tex:ptr = var + %t_s:ptr = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec2 = construct 1.0f, 2.0f - %4:texture_depth_2d_array = load %my_tex + %4:texture_depth_2d_array = load %t_s %5:f32 = convert 4u %6:vec4 = construct %3, %5, 3.0f %7:f32 = glsl.texture %4, %6 @@ -5597,12 +5249,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleCompare_2d_Array) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -5654,13 +5300,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleCompare_2d_Array_Offset) { auto* expect = R"( $B1: { # root - %my_tex:ptr = var + %t_s:ptr = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec2 = construct 1.0f, 2.0f - %4:texture_depth_2d_array = load %my_tex + %4:texture_depth_2d_array = load %t_s %5:f32 = convert 4u %6:vec4 = construct %3, %5, 3.0f %7:vec2 = dpdx %3 @@ -5676,12 +5322,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleCompare_2d_Array_Offset) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -5730,13 +5370,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleCompare_Cube) { auto* expect = R"( $B1: { # root - %my_tex:ptr = var + %t_s:ptr = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec3 = construct 1.0f, 2.0f, 3.0f - %4:texture_depth_cube = load %my_tex + %4:texture_depth_cube = load %t_s %5:vec4 = construct %3, 3.0f %6:f32 = glsl.texture %4, %5 %x:f32 = let %6 @@ -5749,12 +5389,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleCompare_Cube) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -5805,13 +5439,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleCompare_Cube_Array) { auto* expect = R"( $B1: { # root - %my_tex:ptr = var + %t_s:ptr = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec3 = construct 1.0f, 2.0f, 3.0f - %4:texture_depth_cube_array = load %my_tex + %4:texture_depth_cube_array = load %t_s %5:f32 = convert 4u %6:vec4 = construct %3, %5 %7:f32 = glsl.texture %4, %6, 3.0f @@ -5825,12 +5459,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleCompare_Cube_Array) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -5879,13 +5507,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleCompareLevel_2d) { auto* expect = R"( $B1: { # root - %my_tex:ptr = var + %t_s:ptr = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec2 = construct 1.0f, 2.0f - %4:texture_depth_2d = load %my_tex + %4:texture_depth_2d = load %t_s %5:vec3 = construct %3, 3.0f %6:f32 = glsl.texture %4, %5 %x:f32 = let %6 @@ -5898,12 +5526,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleCompareLevel_2d) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -5954,13 +5576,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleCompareLevel_2d_Offset) { auto* expect = R"( $B1: { # root - %my_tex:ptr = var + %t_s:ptr = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec2 = construct 1.0f, 2.0f - %4:texture_depth_2d = load %my_tex + %4:texture_depth_2d = load %t_s %5:vec3 = construct %3, 3.0f %6:f32 = glsl.textureOffset %4, %5, vec2(4i, 5i) %x:f32 = let %6 @@ -5973,12 +5595,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleCompareLevel_2d_Offset) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -6029,13 +5645,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleCompareLevel_2d_Array) { auto* expect = R"( $B1: { # root - %my_tex:ptr = var + %t_s:ptr = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec2 = construct 1.0f, 2.0f - %4:texture_depth_2d_array = load %my_tex + %4:texture_depth_2d_array = load %t_s %5:f32 = convert 4u %6:vec4 = construct %3, %5, 3.0f %7:f32 = glsl.texture %4, %6 @@ -6049,12 +5665,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleCompareLevel_2d_Array) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -6106,13 +5716,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleCompareLevel_2d_Array_Offset auto* expect = R"( $B1: { # root - %my_tex:ptr = var + %t_s:ptr = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec2 = construct 1.0f, 2.0f - %4:texture_depth_2d_array = load %my_tex + %4:texture_depth_2d_array = load %t_s %5:f32 = convert 4u %6:vec4 = construct %3, %5, 3.0f %7:f32 = glsl.textureGradOffset %4, %6, vec2(0.0f), vec2(0.0f), vec2(4i, 5i) @@ -6126,12 +5736,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleCompareLevel_2d_Array_Offset TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -6180,13 +5784,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleCompareLevel_Cube) { auto* expect = R"( $B1: { # root - %my_tex:ptr = var + %t_s:ptr = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec3 = construct 1.0f, 2.0f, 3.0f - %4:texture_depth_cube = load %my_tex + %4:texture_depth_cube = load %t_s %5:vec4 = construct %3, 3.0f %6:f32 = glsl.texture %4, %5 %x:f32 = let %6 @@ -6199,12 +5803,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleCompareLevel_Cube) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } @@ -6255,13 +5853,13 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleCompareLevel_Cube_Array) { auto* expect = R"( $B1: { # root - %my_tex:ptr = var + %t_s:ptr = combined_texture_sampler @binding_point(0, 0) } %foo = @fragment func():void { $B2: { %3:vec3 = construct 1.0f, 2.0f, 3.0f - %4:texture_depth_cube_array = load %my_tex + %4:texture_depth_cube_array = load %t_s %5:f32 = convert 4u %6:vec4 = construct %3, %5 %7:f32 = glsl.texture %4, %6, 3.0f @@ -6275,12 +5873,6 @@ TEST_F(GlslWriter_TexturePolyfillTest, TextureSampleCompareLevel_Cube_Array) { TexturePolyfillConfig cfg; cfg.placeholder_sampler_bind_point = {2, 2}; - - binding::CombinedTextureSamplerPair pair; - pair.texture = {0, 0}; - pair.sampler = {0, 1}; - cfg.sampler_texture_to_name[pair] = "my_tex"; - Run(TexturePolyfill, cfg); EXPECT_EQ(expect, str()); } diff --git a/src/tint/lang/glsl/writer/writer.cc b/src/tint/lang/glsl/writer/writer.cc index b061d8ab83..5a64557a9f 100644 --- a/src/tint/lang/glsl/writer/writer.cc +++ b/src/tint/lang/glsl/writer/writer.cc @@ -41,7 +41,7 @@ Result Generate(core::ir::Module& ir, const Options& options, const std: return res.Failure(); } - return Print(ir, options.version); + return Print(ir, options); } } // namespace tint::glsl::writer