From cd862fdc7c6fde7d3555adfa0daedf1f7856ac91 Mon Sep 17 00:00:00 2001 From: Tomek Ponitka Date: Tue, 8 Sep 2020 16:28:59 +0000 Subject: [PATCH] [spirv-writer] Removing GenerateConstantFloatZeroIfNeeded Bug: tint:143 Change-Id: I81b4ec280264ec175736bae32bf1826d565ed5c0 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28162 Reviewed-by: David Neto Commit-Queue: David Neto --- src/writer/spirv/builder.cc | 15 +++------------ src/writer/spirv/builder.h | 5 ----- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/src/writer/spirv/builder.cc b/src/writer/spirv/builder.cc index 065bca10cc..a36b22e40e 100644 --- a/src/writer/spirv/builder.cc +++ b/src/writer/spirv/builder.cc @@ -1566,8 +1566,9 @@ uint32_t Builder::GenerateTextureIntrinsic(const std::string& name, spirv_params.push_back(std::move(wgsl_params[5])); spirv_params.push_back(Operand::Int(SpvImageOperandsLodMask)); - spirv_params.push_back(Operand::Int( - GenerateConstantFloatZeroIfNeeded(std::move(wgsl_params[0])))); + ast::type::F32Type f32; + ast::FloatLiteral float_0(&f32, 0.0); + spirv_params.push_back(Operand::Int(GenerateLiteralIfNeeded(&float_0))); } if (op == spv::Op::OpNop) { error_ = "unable to determine operator for: " + name; @@ -1606,16 +1607,6 @@ uint32_t Builder::GenerateSampledImage(ast::type::Type* texture_type, return sampled_image.to_i(); } -uint32_t Builder::GenerateConstantFloatZeroIfNeeded(Operand float_operand) { - if (constant_float_zero_id_ == 0) { - auto float_0 = result_op(); - push_type(spv::Op::OpConstant, - {std::move(float_operand), float_0, Operand::Int(0)}); - constant_float_zero_id_ = float_0.to_i(); - } - return constant_float_zero_id_; -} - uint32_t Builder::GenerateAsExpression(ast::AsExpression* as) { auto result = result_op(); auto result_id = result.to_i(); diff --git a/src/writer/spirv/builder.h b/src/writer/spirv/builder.h index 1f828f8886..4630f5376d 100644 --- a/src/writer/spirv/builder.h +++ b/src/writer/spirv/builder.h @@ -302,10 +302,6 @@ class Builder { uint32_t GenerateSampledImage(ast::type::Type* texture_type, Operand texture_operand, Operand sampler_operand); - /// Generates a constant float zero. - /// @param float_operand the f32 type operand - /// @returns the expression ID - uint32_t GenerateConstantFloatZeroIfNeeded(Operand float_operand); /// Generates a cast expression /// @param expr the expression to generate /// @returns the expression ID on success or 0 otherwise @@ -450,7 +446,6 @@ class Builder { std::unordered_map spirv_id_to_variable_; std::vector merge_stack_; std::vector continue_stack_; - uint32_t constant_float_zero_id_ = 0; }; } // namespace spirv