mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-06-06 22:53:35 +00:00
Have TypesBuilder pointer and structure methods return ast types
These were the last two types to migrate away from typ::TypePair. Bug: tint:724 Change-Id: Ibc03e35db00236081a5792f787864ab69ce0d00c Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/51665 Commit-Queue: Ben Clayton <bclayton@google.com> Auto-Submit: Ben Clayton <bclayton@google.com> Reviewed-by: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
parent
d3e80fd36c
commit
37c4e4a41d
@ -62,7 +62,7 @@ class InspectorHelper : public ProgramBuilder {
|
|||||||
/// Generates a struct that contains user-defined IO members
|
/// Generates a struct that contains user-defined IO members
|
||||||
/// @param name the name of the generated struct
|
/// @param name the name of the generated struct
|
||||||
/// @param inout_vars tuples of {name, loc} that will be the struct members
|
/// @param inout_vars tuples of {name, loc} that will be the struct members
|
||||||
typ::Struct MakeInOutStruct(
|
ast::Struct* MakeInOutStruct(
|
||||||
std::string name,
|
std::string name,
|
||||||
std::vector<std::tuple<std::string, uint32_t>> inout_vars) {
|
std::vector<std::tuple<std::string, uint32_t>> inout_vars) {
|
||||||
ast::StructMemberList members;
|
ast::StructMemberList members;
|
||||||
@ -1005,7 +1005,7 @@ TEST_F(InspectorGetEntryPointTest, BuiltInsNotStageVariables) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(InspectorGetEntryPointTest, InOutStruct) {
|
TEST_F(InspectorGetEntryPointTest, InOutStruct) {
|
||||||
auto interface = MakeInOutStruct("interface", {{"a", 0u}, {"b", 1u}});
|
auto* interface = MakeInOutStruct("interface", {{"a", 0u}, {"b", 1u}});
|
||||||
Func("foo", {Param("param", interface)}, interface, {Return("param")},
|
Func("foo", {Param("param", interface)}, interface, {Return("param")},
|
||||||
{Stage(ast::PipelineStage::kFragment)});
|
{Stage(ast::PipelineStage::kFragment)});
|
||||||
Inspector& inspector = Build();
|
Inspector& inspector = Build();
|
||||||
@ -1037,7 +1037,7 @@ TEST_F(InspectorGetEntryPointTest, InOutStruct) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(InspectorGetEntryPointTest, MultipleEntryPointsInOutSharedStruct) {
|
TEST_F(InspectorGetEntryPointTest, MultipleEntryPointsInOutSharedStruct) {
|
||||||
auto interface = MakeInOutStruct("interface", {{"a", 0u}, {"b", 1u}});
|
auto* interface = MakeInOutStruct("interface", {{"a", 0u}, {"b", 1u}});
|
||||||
Func("foo", {}, interface, {Return(Construct(interface))},
|
Func("foo", {}, interface, {Return(Construct(interface))},
|
||||||
{Stage(ast::PipelineStage::kFragment)});
|
{Stage(ast::PipelineStage::kFragment)});
|
||||||
Func("bar", {Param("param", interface)}, ty.void_(), {},
|
Func("bar", {Param("param", interface)}, ty.void_(), {},
|
||||||
@ -1075,8 +1075,8 @@ TEST_F(InspectorGetEntryPointTest, MultipleEntryPointsInOutSharedStruct) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(InspectorGetEntryPointTest, MixInOutVariablesAndStruct) {
|
TEST_F(InspectorGetEntryPointTest, MixInOutVariablesAndStruct) {
|
||||||
auto struct_a = MakeInOutStruct("struct_a", {{"a", 0u}, {"b", 1u}});
|
auto* struct_a = MakeInOutStruct("struct_a", {{"a", 0u}, {"b", 1u}});
|
||||||
auto struct_b = MakeInOutStruct("struct_b", {{"a", 2u}});
|
auto* struct_b = MakeInOutStruct("struct_b", {{"a", 2u}});
|
||||||
Func("foo",
|
Func("foo",
|
||||||
{Param("param_a", struct_a), Param("param_b", struct_b),
|
{Param("param_a", struct_a), Param("param_b", struct_b),
|
||||||
Param("param_c", ty.f32(), {Location(3u)}),
|
Param("param_c", ty.f32(), {Location(3u)}),
|
||||||
@ -1659,7 +1659,7 @@ TEST_F(InspectorGetResourceBindingsTest, Empty) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(InspectorGetResourceBindingsTest, Simple) {
|
TEST_F(InspectorGetResourceBindingsTest, Simple) {
|
||||||
typ::Struct ub_struct_type = MakeUniformBufferType("ub_type", {ty.i32()});
|
ast::Struct* ub_struct_type = MakeUniformBufferType("ub_type", {ty.i32()});
|
||||||
AddUniformBuffer("ub_var", ub_struct_type, 0, 0);
|
AddUniformBuffer("ub_var", ub_struct_type, 0, 0);
|
||||||
MakeStructVariableReferenceBodyFunction("ub_func", "ub_var", {{0, ty.i32()}});
|
MakeStructVariableReferenceBodyFunction("ub_func", "ub_var", {{0, ty.i32()}});
|
||||||
|
|
||||||
@ -1766,7 +1766,7 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, MissingEntryPoint) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(InspectorGetUniformBufferResourceBindingsTest, NonEntryPointFunc) {
|
TEST_F(InspectorGetUniformBufferResourceBindingsTest, NonEntryPointFunc) {
|
||||||
typ::Struct foo_struct_type = MakeUniformBufferType("foo_type", {ty.i32()});
|
ast::Struct* foo_struct_type = MakeUniformBufferType("foo_type", {ty.i32()});
|
||||||
AddUniformBuffer("foo_ub", foo_struct_type, 0, 0);
|
AddUniformBuffer("foo_ub", foo_struct_type, 0, 0);
|
||||||
|
|
||||||
MakeStructVariableReferenceBodyFunction("ub_func", "foo_ub", {{0, ty.i32()}});
|
MakeStructVariableReferenceBodyFunction("ub_func", "foo_ub", {{0, ty.i32()}});
|
||||||
@ -1784,7 +1784,7 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, NonEntryPointFunc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(InspectorGetUniformBufferResourceBindingsTest, Simple) {
|
TEST_F(InspectorGetUniformBufferResourceBindingsTest, Simple) {
|
||||||
typ::Struct foo_struct_type = MakeUniformBufferType("foo_type", {ty.i32()});
|
ast::Struct* foo_struct_type = MakeUniformBufferType("foo_type", {ty.i32()});
|
||||||
AddUniformBuffer("foo_ub", foo_struct_type, 0, 0);
|
AddUniformBuffer("foo_ub", foo_struct_type, 0, 0);
|
||||||
|
|
||||||
MakeStructVariableReferenceBodyFunction("ub_func", "foo_ub", {{0, ty.i32()}});
|
MakeStructVariableReferenceBodyFunction("ub_func", "foo_ub", {{0, ty.i32()}});
|
||||||
@ -1809,7 +1809,7 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, Simple) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleMembers) {
|
TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleMembers) {
|
||||||
typ::Struct foo_struct_type =
|
ast::Struct* foo_struct_type =
|
||||||
MakeUniformBufferType("foo_type", {ty.i32(), ty.u32(), ty.f32()});
|
MakeUniformBufferType("foo_type", {ty.i32(), ty.u32(), ty.f32()});
|
||||||
AddUniformBuffer("foo_ub", foo_struct_type, 0, 0);
|
AddUniformBuffer("foo_ub", foo_struct_type, 0, 0);
|
||||||
|
|
||||||
@ -1836,7 +1836,7 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleMembers) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(InspectorGetUniformBufferResourceBindingsTest, ContainingPadding) {
|
TEST_F(InspectorGetUniformBufferResourceBindingsTest, ContainingPadding) {
|
||||||
typ::Struct foo_struct_type =
|
ast::Struct* foo_struct_type =
|
||||||
MakeUniformBufferType("foo_type", {ty.vec3<f32>()});
|
MakeUniformBufferType("foo_type", {ty.vec3<f32>()});
|
||||||
AddUniformBuffer("foo_ub", foo_struct_type, 0, 0);
|
AddUniformBuffer("foo_ub", foo_struct_type, 0, 0);
|
||||||
|
|
||||||
@ -1863,7 +1863,7 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, ContainingPadding) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleUniformBuffers) {
|
TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleUniformBuffers) {
|
||||||
typ::Struct ub_struct_type =
|
ast::Struct* ub_struct_type =
|
||||||
MakeUniformBufferType("ub_type", {ty.i32(), ty.u32(), ty.f32()});
|
MakeUniformBufferType("ub_type", {ty.i32(), ty.u32(), ty.f32()});
|
||||||
AddUniformBuffer("ub_foo", ub_struct_type, 0, 0);
|
AddUniformBuffer("ub_foo", ub_struct_type, 0, 0);
|
||||||
AddUniformBuffer("ub_bar", ub_struct_type, 0, 1);
|
AddUniformBuffer("ub_bar", ub_struct_type, 0, 1);
|
||||||
@ -1921,7 +1921,7 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, ContainingArray) {
|
|||||||
// TODO(bclayton) - This is not a legal structure layout for uniform buffer
|
// TODO(bclayton) - This is not a legal structure layout for uniform buffer
|
||||||
// usage. Once crbug.com/tint/628 is implemented, this will fail validation
|
// usage. Once crbug.com/tint/628 is implemented, this will fail validation
|
||||||
// and will need to be fixed.
|
// and will need to be fixed.
|
||||||
typ::Struct foo_struct_type =
|
ast::Struct* foo_struct_type =
|
||||||
MakeUniformBufferType("foo_type", {ty.i32(), ty.array<u32, 4>()});
|
MakeUniformBufferType("foo_type", {ty.i32(), ty.array<u32, 4>()});
|
||||||
AddUniformBuffer("foo_ub", foo_struct_type, 0, 0);
|
AddUniformBuffer("foo_ub", foo_struct_type, 0, 0);
|
||||||
|
|
||||||
|
@ -710,10 +710,7 @@ class ProgramBuilder {
|
|||||||
typ::Pointer pointer(typ::Type type,
|
typ::Pointer pointer(typ::Type type,
|
||||||
ast::StorageClass storage_class) const {
|
ast::StorageClass storage_class) const {
|
||||||
type = MaybeCreateTypename(type);
|
type = MaybeCreateTypename(type);
|
||||||
return {type.ast ? builder->create<ast::Pointer>(type, storage_class)
|
return {builder->create<ast::Pointer>(type, storage_class)};
|
||||||
: nullptr,
|
|
||||||
type.sem ? builder->create<sem::Pointer>(type, storage_class)
|
|
||||||
: nullptr};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @param source the Source of the node
|
/// @param source the Source of the node
|
||||||
@ -724,11 +721,7 @@ class ProgramBuilder {
|
|||||||
typ::Type type,
|
typ::Type type,
|
||||||
ast::StorageClass storage_class) const {
|
ast::StorageClass storage_class) const {
|
||||||
type = MaybeCreateTypename(type);
|
type = MaybeCreateTypename(type);
|
||||||
return {type.ast
|
return {builder->create<ast::Pointer>(source, type, storage_class)};
|
||||||
? builder->create<ast::Pointer>(source, type, storage_class)
|
|
||||||
: nullptr,
|
|
||||||
type.sem ? builder->create<sem::Pointer>(type, storage_class)
|
|
||||||
: nullptr};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @param storage_class the storage class of the pointer
|
/// @param storage_class the storage class of the pointer
|
||||||
|
@ -237,8 +237,6 @@ bool operator!=(std::nullptr_t, const TypePair<AST, SEM>& rhs) {
|
|||||||
|
|
||||||
using Type = TypePair<ast::Type, sem::Type>;
|
using Type = TypePair<ast::Type, sem::Type>;
|
||||||
|
|
||||||
using Pointer = TypePair<ast::Pointer, sem::Pointer>;
|
|
||||||
using Struct = TypePair<ast::Struct, sem::Struct>;
|
|
||||||
|
|
||||||
using Bool = Ptr<ast::Bool>;
|
using Bool = Ptr<ast::Bool>;
|
||||||
using U32 = Ptr<ast::U32>;
|
using U32 = Ptr<ast::U32>;
|
||||||
@ -254,6 +252,8 @@ using Texture = Ptr<ast::Texture>;
|
|||||||
using Sampler = Ptr<ast::Sampler>;
|
using Sampler = Ptr<ast::Sampler>;
|
||||||
using Matrix = Ptr<ast::Matrix>;
|
using Matrix = Ptr<ast::Matrix>;
|
||||||
using Vector = Ptr<ast::Vector>;
|
using Vector = Ptr<ast::Vector>;
|
||||||
|
using Pointer = Ptr<ast::Pointer>;
|
||||||
|
using Struct = Ptr<ast::Struct>;
|
||||||
|
|
||||||
// Helpers
|
// Helpers
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user