mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 02:39:11 +00:00
Add ProgramID feed it into all ast::Nodes
This will be used to detect accidental leaks of program objects between programs. Bug: tint:709 Change-Id: I20f784a2c673d19a04a880b3ec91dfe2eb743bdb Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47622 Commit-Queue: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Antonio Maiorano <amaiorano@google.com> Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
committed by
Commit Bot service account
parent
f01ed13a25
commit
e6995de232
@@ -51,7 +51,9 @@ struct ArrayUsage {
|
||||
|
||||
} // namespace
|
||||
|
||||
CalculateArrayLength::BufferSizeIntrinsic::BufferSizeIntrinsic() = default;
|
||||
CalculateArrayLength::BufferSizeIntrinsic::BufferSizeIntrinsic(
|
||||
ProgramID program_id)
|
||||
: Base(program_id) {}
|
||||
CalculateArrayLength::BufferSizeIntrinsic::~BufferSizeIntrinsic() = default;
|
||||
std::string CalculateArrayLength::BufferSizeIntrinsic::Name() const {
|
||||
return "intrinsic_buffer_size";
|
||||
@@ -59,8 +61,8 @@ std::string CalculateArrayLength::BufferSizeIntrinsic::Name() const {
|
||||
|
||||
CalculateArrayLength::BufferSizeIntrinsic*
|
||||
CalculateArrayLength::BufferSizeIntrinsic::Clone(CloneContext* ctx) const {
|
||||
return ctx->dst->ASTNodes()
|
||||
.Create<CalculateArrayLength::BufferSizeIntrinsic>();
|
||||
return ctx->dst->ASTNodes().Create<CalculateArrayLength::BufferSizeIntrinsic>(
|
||||
ctx->dst->ID());
|
||||
}
|
||||
|
||||
CalculateArrayLength::CalculateArrayLength() = default;
|
||||
@@ -93,7 +95,7 @@ Transform::Output CalculateArrayLength::Run(const Program* in, const DataMap&) {
|
||||
},
|
||||
ctx.dst->ty.void_(), nullptr,
|
||||
ast::DecorationList{
|
||||
ctx.dst->ASTNodes().Create<BufferSizeIntrinsic>(),
|
||||
ctx.dst->ASTNodes().Create<BufferSizeIntrinsic>(ctx.dst->ID()),
|
||||
},
|
||||
ast::DecorationList{});
|
||||
ctx.InsertAfter(ctx.src->AST().GlobalDeclarations(), buffer_type, func);
|
||||
|
||||
@@ -37,7 +37,8 @@ class CalculateArrayLength : public Transform {
|
||||
: public Castable<BufferSizeIntrinsic, ast::InternalDecoration> {
|
||||
public:
|
||||
/// Constructor
|
||||
BufferSizeIntrinsic();
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
explicit BufferSizeIntrinsic(ProgramID program_id);
|
||||
/// Destructor
|
||||
~BufferSizeIntrinsic() override;
|
||||
|
||||
|
||||
@@ -203,48 +203,52 @@ DecomposeStorageAccess::Intrinsic* IntrinsicLoadFor(ProgramBuilder* builder,
|
||||
type::Type* ty) {
|
||||
using Intrinsic = DecomposeStorageAccess::Intrinsic;
|
||||
|
||||
auto intrinsic = [builder](Intrinsic::Type type) {
|
||||
return builder->ASTNodes().Create<Intrinsic>(builder->ID(), type);
|
||||
};
|
||||
|
||||
if (ty->Is<type::I32>()) {
|
||||
return builder->ASTNodes().Create<Intrinsic>(Intrinsic::kLoadI32);
|
||||
return intrinsic(Intrinsic::kLoadI32);
|
||||
}
|
||||
if (ty->Is<type::U32>()) {
|
||||
return builder->ASTNodes().Create<Intrinsic>(Intrinsic::kLoadU32);
|
||||
return intrinsic(Intrinsic::kLoadU32);
|
||||
}
|
||||
if (ty->Is<type::F32>()) {
|
||||
return builder->ASTNodes().Create<Intrinsic>(Intrinsic::kLoadF32);
|
||||
return intrinsic(Intrinsic::kLoadF32);
|
||||
}
|
||||
if (auto* vec = ty->As<type::Vector>()) {
|
||||
switch (vec->size()) {
|
||||
case 2:
|
||||
if (vec->type()->Is<type::I32>()) {
|
||||
return builder->ASTNodes().Create<Intrinsic>(Intrinsic::kLoadVec2I32);
|
||||
return intrinsic(Intrinsic::kLoadVec2I32);
|
||||
}
|
||||
if (vec->type()->Is<type::U32>()) {
|
||||
return builder->ASTNodes().Create<Intrinsic>(Intrinsic::kLoadVec2U32);
|
||||
return intrinsic(Intrinsic::kLoadVec2U32);
|
||||
}
|
||||
if (vec->type()->Is<type::F32>()) {
|
||||
return builder->ASTNodes().Create<Intrinsic>(Intrinsic::kLoadVec2F32);
|
||||
return intrinsic(Intrinsic::kLoadVec2F32);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (vec->type()->Is<type::I32>()) {
|
||||
return builder->ASTNodes().Create<Intrinsic>(Intrinsic::kLoadVec3I32);
|
||||
return intrinsic(Intrinsic::kLoadVec3I32);
|
||||
}
|
||||
if (vec->type()->Is<type::U32>()) {
|
||||
return builder->ASTNodes().Create<Intrinsic>(Intrinsic::kLoadVec3U32);
|
||||
return intrinsic(Intrinsic::kLoadVec3U32);
|
||||
}
|
||||
if (vec->type()->Is<type::F32>()) {
|
||||
return builder->ASTNodes().Create<Intrinsic>(Intrinsic::kLoadVec3F32);
|
||||
return intrinsic(Intrinsic::kLoadVec3F32);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if (vec->type()->Is<type::I32>()) {
|
||||
return builder->ASTNodes().Create<Intrinsic>(Intrinsic::kLoadVec4I32);
|
||||
return intrinsic(Intrinsic::kLoadVec4I32);
|
||||
}
|
||||
if (vec->type()->Is<type::U32>()) {
|
||||
return builder->ASTNodes().Create<Intrinsic>(Intrinsic::kLoadVec4U32);
|
||||
return intrinsic(Intrinsic::kLoadVec4U32);
|
||||
}
|
||||
if (vec->type()->Is<type::F32>()) {
|
||||
return builder->ASTNodes().Create<Intrinsic>(Intrinsic::kLoadVec4F32);
|
||||
return intrinsic(Intrinsic::kLoadVec4F32);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -258,57 +262,52 @@ DecomposeStorageAccess::Intrinsic* IntrinsicStoreFor(ProgramBuilder* builder,
|
||||
type::Type* ty) {
|
||||
using Intrinsic = DecomposeStorageAccess::Intrinsic;
|
||||
|
||||
auto intrinsic = [builder](Intrinsic::Type type) {
|
||||
return builder->ASTNodes().Create<Intrinsic>(builder->ID(), type);
|
||||
};
|
||||
|
||||
if (ty->Is<type::I32>()) {
|
||||
return builder->ASTNodes().Create<Intrinsic>(Intrinsic::kStoreI32);
|
||||
return intrinsic(Intrinsic::kStoreI32);
|
||||
}
|
||||
if (ty->Is<type::U32>()) {
|
||||
return builder->ASTNodes().Create<Intrinsic>(Intrinsic::kStoreU32);
|
||||
return intrinsic(Intrinsic::kStoreU32);
|
||||
}
|
||||
if (ty->Is<type::F32>()) {
|
||||
return builder->ASTNodes().Create<Intrinsic>(Intrinsic::kStoreF32);
|
||||
return intrinsic(Intrinsic::kStoreF32);
|
||||
}
|
||||
if (auto* vec = ty->As<type::Vector>()) {
|
||||
switch (vec->size()) {
|
||||
case 2:
|
||||
if (vec->type()->Is<type::I32>()) {
|
||||
return builder->ASTNodes().Create<Intrinsic>(
|
||||
Intrinsic::kStoreVec2U32);
|
||||
return intrinsic(Intrinsic::kStoreVec2U32);
|
||||
}
|
||||
if (vec->type()->Is<type::U32>()) {
|
||||
return builder->ASTNodes().Create<Intrinsic>(
|
||||
Intrinsic::kStoreVec2F32);
|
||||
return intrinsic(Intrinsic::kStoreVec2F32);
|
||||
}
|
||||
if (vec->type()->Is<type::F32>()) {
|
||||
return builder->ASTNodes().Create<Intrinsic>(
|
||||
Intrinsic::kStoreVec2I32);
|
||||
return intrinsic(Intrinsic::kStoreVec2I32);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (vec->type()->Is<type::I32>()) {
|
||||
return builder->ASTNodes().Create<Intrinsic>(
|
||||
Intrinsic::kStoreVec3U32);
|
||||
return intrinsic(Intrinsic::kStoreVec3U32);
|
||||
}
|
||||
if (vec->type()->Is<type::U32>()) {
|
||||
return builder->ASTNodes().Create<Intrinsic>(
|
||||
Intrinsic::kStoreVec3F32);
|
||||
return intrinsic(Intrinsic::kStoreVec3F32);
|
||||
}
|
||||
if (vec->type()->Is<type::F32>()) {
|
||||
return builder->ASTNodes().Create<Intrinsic>(
|
||||
Intrinsic::kStoreVec3I32);
|
||||
return intrinsic(Intrinsic::kStoreVec3I32);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if (vec->type()->Is<type::I32>()) {
|
||||
return builder->ASTNodes().Create<Intrinsic>(
|
||||
Intrinsic::kStoreVec4U32);
|
||||
return intrinsic(Intrinsic::kStoreVec4U32);
|
||||
}
|
||||
if (vec->type()->Is<type::U32>()) {
|
||||
return builder->ASTNodes().Create<Intrinsic>(
|
||||
Intrinsic::kStoreVec4F32);
|
||||
return intrinsic(Intrinsic::kStoreVec4F32);
|
||||
}
|
||||
if (vec->type()->Is<type::F32>()) {
|
||||
return builder->ASTNodes().Create<Intrinsic>(
|
||||
Intrinsic::kStoreVec4I32);
|
||||
return intrinsic(Intrinsic::kStoreVec4I32);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -544,7 +543,8 @@ struct State {
|
||||
|
||||
} // namespace
|
||||
|
||||
DecomposeStorageAccess::Intrinsic::Intrinsic(Type ty) : type(ty) {}
|
||||
DecomposeStorageAccess::Intrinsic::Intrinsic(ProgramID program_id, Type ty)
|
||||
: Base(program_id), type(ty) {}
|
||||
DecomposeStorageAccess::Intrinsic::~Intrinsic() = default;
|
||||
std::string DecomposeStorageAccess::Intrinsic::Name() const {
|
||||
switch (type) {
|
||||
@@ -602,7 +602,8 @@ std::string DecomposeStorageAccess::Intrinsic::Name() const {
|
||||
|
||||
DecomposeStorageAccess::Intrinsic* DecomposeStorageAccess::Intrinsic::Clone(
|
||||
CloneContext* ctx) const {
|
||||
return ctx->dst->ASTNodes().Create<DecomposeStorageAccess::Intrinsic>(type);
|
||||
return ctx->dst->ASTNodes().Create<DecomposeStorageAccess::Intrinsic>(
|
||||
ctx->dst->ID(), type);
|
||||
}
|
||||
|
||||
DecomposeStorageAccess::DecomposeStorageAccess() = default;
|
||||
|
||||
@@ -66,8 +66,9 @@ class DecomposeStorageAccess : public Transform {
|
||||
};
|
||||
|
||||
/// Constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param ty the type of the intrinsic
|
||||
explicit Intrinsic(Type ty);
|
||||
Intrinsic(ProgramID program_id, Type ty);
|
||||
/// Destructor
|
||||
~Intrinsic() override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user