tint: Use ProgramBuilder::Discard()
Change-Id: If71a771a65510ec7daa003f02958002d3fa83e3b Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118983 Reviewed-by: James Price <jrprice@google.com> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
17aa653fa9
commit
6adb65c488
|
@ -3137,7 +3137,7 @@ bool FunctionEmitter::EmitNormalTerminator(const BlockInfo& block_info) {
|
|||
case spv::Op::OpKill:
|
||||
// For now, assume SPIR-V OpKill has same semantics as WGSL discard.
|
||||
// TODO(dneto): https://github.com/gpuweb/gpuweb/issues/676
|
||||
AddStatement(create<ast::DiscardStatement>(Source{}));
|
||||
AddStatement(builder_.Discard(Source{}));
|
||||
return true;
|
||||
case spv::Op::OpUnreachable:
|
||||
// Translate as if it's a return. This avoids the problem where WGSL
|
||||
|
|
|
@ -1866,7 +1866,7 @@ Maybe<const ast::Statement*> ParserImpl::non_block_statement() {
|
|||
|
||||
Source source;
|
||||
if (match(Token::Type::kDiscard, &source)) {
|
||||
return create<ast::DiscardStatement>(source);
|
||||
return builder_.Discard(source);
|
||||
}
|
||||
|
||||
// Note, this covers assignment, increment and decrement
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace {
|
|||
using GlslGeneratorImplTest_Discard = TestHelper;
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_Discard, Emit_Discard) {
|
||||
auto* stmt = create<ast::DiscardStatement>();
|
||||
auto* stmt = Discard();
|
||||
|
||||
Func("F", utils::Empty, ty.void_(), utils::Vector{stmt},
|
||||
utils::Vector{Stage(ast::PipelineStage::kFragment)});
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace {
|
|||
using HlslGeneratorImplTest_Discard = TestHelper;
|
||||
|
||||
TEST_F(HlslGeneratorImplTest_Discard, Emit_Discard) {
|
||||
auto* stmt = create<ast::DiscardStatement>();
|
||||
auto* stmt = Discard();
|
||||
|
||||
Func("F", utils::Empty, ty.void_(), utils::Vector{stmt},
|
||||
utils::Vector{Stage(ast::PipelineStage::kFragment)});
|
||||
|
|
|
@ -769,7 +769,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function_WithDiscardAndVoidReturn) {
|
|||
Func("my_func", utils::Vector{Param("a", ty.i32())}, ty.void_(),
|
||||
utils::Vector{
|
||||
If(Equal("a", 0_i), //
|
||||
Block(create<ast::DiscardStatement>())),
|
||||
Block(Discard())),
|
||||
Return(),
|
||||
});
|
||||
|
||||
|
@ -789,7 +789,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function_WithDiscardAndNonVoidReturn
|
|||
Func("my_func", utils::Vector{Param("a", ty.i32())}, ty.i32(),
|
||||
utils::Vector{
|
||||
If(Equal("a", 0_i), //
|
||||
Block(create<ast::DiscardStatement>())),
|
||||
Block(Discard())),
|
||||
Return(42_i),
|
||||
});
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace {
|
|||
using MslGeneratorImplTest = TestHelper;
|
||||
|
||||
TEST_F(MslGeneratorImplTest, Emit_Discard) {
|
||||
auto* stmt = create<ast::DiscardStatement>();
|
||||
auto* stmt = Discard();
|
||||
|
||||
Func("F", utils::Empty, ty.void_(), utils::Vector{stmt},
|
||||
utils::Vector{Stage(ast::PipelineStage::kFragment)});
|
||||
|
|
|
@ -90,7 +90,7 @@ OpFunctionEnd
|
|||
TEST_F(BuilderTest, Function_Terminator_Discard) {
|
||||
Func("a_func", utils::Empty, ty.void_(),
|
||||
utils::Vector{
|
||||
create<ast::DiscardStatement>(),
|
||||
Discard(),
|
||||
});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace {
|
|||
using WgslGeneratorImplTest = TestHelper;
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, Emit_Discard) {
|
||||
auto* stmt = create<ast::DiscardStatement>();
|
||||
auto* stmt = Discard();
|
||||
|
||||
Func("F", utils::Empty, ty.void_(), utils::Vector{stmt},
|
||||
utils::Vector{Stage(ast::PipelineStage::kFragment)});
|
||||
|
|
|
@ -68,7 +68,7 @@ TEST_F(WgslGeneratorImplTest, Emit_LoopWithContinuing) {
|
|||
TEST_F(WgslGeneratorImplTest, Emit_LoopWithContinuing_BreakIf) {
|
||||
Func("a_statement", {}, ty.void_(), {});
|
||||
|
||||
auto* body = Block(create<ast::DiscardStatement>());
|
||||
auto* body = Block(Discard());
|
||||
auto* continuing = Block(CallStmt(Call("a_statement")), BreakIf(true));
|
||||
auto* l = Loop(body, continuing);
|
||||
|
||||
|
|
Loading…
Reference in New Issue