[spirv-writer] Removing GenerateConstantFloatZeroIfNeeded

Bug: tint:143
Change-Id: I81b4ec280264ec175736bae32bf1826d565ed5c0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28162
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
This commit is contained in:
Tomek Ponitka 2020-09-08 16:28:59 +00:00 committed by Commit Bot service account
parent e4f60fa0be
commit cd862fdc7c
2 changed files with 3 additions and 17 deletions

View File

@ -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(std::move(wgsl_params[5]));
spirv_params.push_back(Operand::Int(SpvImageOperandsLodMask)); spirv_params.push_back(Operand::Int(SpvImageOperandsLodMask));
spirv_params.push_back(Operand::Int( ast::type::F32Type f32;
GenerateConstantFloatZeroIfNeeded(std::move(wgsl_params[0])))); ast::FloatLiteral float_0(&f32, 0.0);
spirv_params.push_back(Operand::Int(GenerateLiteralIfNeeded(&float_0)));
} }
if (op == spv::Op::OpNop) { if (op == spv::Op::OpNop) {
error_ = "unable to determine operator for: " + name; 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(); 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) { uint32_t Builder::GenerateAsExpression(ast::AsExpression* as) {
auto result = result_op(); auto result = result_op();
auto result_id = result.to_i(); auto result_id = result.to_i();

View File

@ -302,10 +302,6 @@ class Builder {
uint32_t GenerateSampledImage(ast::type::Type* texture_type, uint32_t GenerateSampledImage(ast::type::Type* texture_type,
Operand texture_operand, Operand texture_operand,
Operand sampler_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 /// Generates a cast expression
/// @param expr the expression to generate /// @param expr the expression to generate
/// @returns the expression ID on success or 0 otherwise /// @returns the expression ID on success or 0 otherwise
@ -450,7 +446,6 @@ class Builder {
std::unordered_map<uint32_t, ast::Variable*> spirv_id_to_variable_; std::unordered_map<uint32_t, ast::Variable*> spirv_id_to_variable_;
std::vector<uint32_t> merge_stack_; std::vector<uint32_t> merge_stack_;
std::vector<uint32_t> continue_stack_; std::vector<uint32_t> continue_stack_;
uint32_t constant_float_zero_id_ = 0;
}; };
} // namespace spirv } // namespace spirv