Change test terminology to reflect WebGPU spec

The spec explicitly refers to these as uniform buffers, not uniform
buffer objects (UBOs).

Change-Id: Ia825f8ddd64fe9a3c20fb10914c6446346fc0217
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31001
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
This commit is contained in:
Ryan Harrison 2020-10-26 20:11:48 +00:00 committed by Commit Bot service account
parent 1bafdc3c45
commit 57694c8dab
1 changed files with 61 additions and 62 deletions

View File

@ -254,12 +254,12 @@ class InspectorHelper {
return std::to_string(idx) + type->type_name(); return std::to_string(idx) + type->type_name();
} }
/// Generates a struct type appropriate for using in a UBO /// Generates a struct type appropriate for using in an uniform buffer
/// @param name name for the type /// @param name name for the type
/// @param members_info a vector of {type, offset} where each entry is the /// @param members_info a vector of {type, offset} where each entry is the
/// type and offset of a member of the struct /// type and offset of a member of the struct
/// @returns a struct type suitable to use for a UBO /// @returns a struct type suitable to use for an uniform buffer
std::unique_ptr<ast::type::StructType> MakeUBOStructType( std::unique_ptr<ast::type::StructType> MakeUniformBufferStructType(
const std::string& name, const std::string& name,
std::vector<std::tuple<ast::type::Type*, uint32_t>> members_info) { std::vector<std::tuple<ast::type::Type*, uint32_t>> members_info) {
ast::StructMemberList members; ast::StructMemberList members;
@ -284,12 +284,12 @@ class InspectorHelper {
return std::make_unique<ast::type::StructType>(name, std::move(str)); return std::make_unique<ast::type::StructType>(name, std::move(str));
} }
/// Adds a UBO variable to the module /// Adds an uniform buffer variable to the module
/// @param name the name of the variable /// @param name the name of the variable
/// @param struct_type the type to use /// @param struct_type the type to use
/// @param set the binding group/set to use for the UBO /// @param set the binding group/set to use for the uniform buffer
/// @param binding the binding number to use for the UBO /// @param binding the binding number to use for the uniform buffer
void AddUBO(const std::string& name, void AddUniformBuffer(const std::string& name,
ast::type::StructType* struct_type, ast::type::StructType* struct_type,
uint32_t set, uint32_t set,
uint32_t binding) { uint32_t binding) {
@ -305,14 +305,14 @@ class InspectorHelper {
mod()->AddGlobalVariable(std::move(var)); mod()->AddGlobalVariable(std::move(var));
} }
/// Generates a function that references a specific UBO /// Generates a function that references a specific uniform buffer
/// @param func_name name of the function created /// @param func_name name of the function created
/// @param ubo_name name of the UBO to be accessed /// @param ub_name name of the uniform buffer to be accessed
/// @param members list of members to access, by index and type /// @param members list of members to access, by index and type
/// @returns a function that references all of the UBO members specified /// @returns a function that references all of the ub members specified
std::unique_ptr<ast::Function> MakeUBOReferenceBodyFunction( std::unique_ptr<ast::Function> MakeUniformBufferReferenceBodyFunction(
std::string func_name, std::string func_name,
std::string ubo_name, std::string ub_name,
std::vector<std::tuple<size_t, ast::type::Type*>> members) { std::vector<std::tuple<size_t, ast::type::Type*>> members) {
auto body = std::make_unique<ast::BlockStatement>(); auto body = std::make_unique<ast::BlockStatement>();
@ -334,7 +334,7 @@ class InspectorHelper {
body->append(std::make_unique<ast::AssignmentStatement>( body->append(std::make_unique<ast::AssignmentStatement>(
std::make_unique<ast::IdentifierExpression>("local" + member_name), std::make_unique<ast::IdentifierExpression>("local" + member_name),
std::make_unique<ast::MemberAccessorExpression>( std::make_unique<ast::MemberAccessorExpression>(
std::make_unique<ast::IdentifierExpression>(ubo_name), std::make_unique<ast::IdentifierExpression>(ub_name),
std::make_unique<ast::IdentifierExpression>(member_name)))); std::make_unique<ast::IdentifierExpression>(member_name))));
} }
@ -798,21 +798,21 @@ TEST_F(InspectorGetUniformBufferResourceBindings, MissingEntryPoint) {
} }
TEST_F(InspectorGetUniformBufferResourceBindings, NonEntryPointFunc) { TEST_F(InspectorGetUniformBufferResourceBindings, NonEntryPointFunc) {
auto foo_type = MakeUBOStructType("foo_type", {{i32_type(), 0}}); auto foo_type = MakeUniformBufferStructType("foo_type", {{i32_type(), 0}});
AddUBO("foo_ubo", foo_type.get(), 0, 0); AddUniformBuffer("foo_ub", foo_type.get(), 0, 0);
auto ubo_func = auto ub_func = MakeUniformBufferReferenceBodyFunction("ub_func", "foo_ub",
MakeUBOReferenceBodyFunction("ubo_func", "foo_ubo", {{0, i32_type()}}); {{0, i32_type()}});
mod()->AddFunction(std::move(ubo_func)); mod()->AddFunction(std::move(ub_func));
auto ep_func = MakeCallerBodyFunction("ep_func", "ubo_func"); auto ep_func = MakeCallerBodyFunction("ep_func", "ub_func");
ep_func->add_decoration( ep_func->add_decoration(
std::make_unique<ast::StageDecoration>(ast::PipelineStage::kVertex)); std::make_unique<ast::StageDecoration>(ast::PipelineStage::kVertex));
mod()->AddFunction(std::move(ep_func)); mod()->AddFunction(std::move(ep_func));
ASSERT_TRUE(td()->Determine()) << td()->error(); ASSERT_TRUE(td()->Determine()) << td()->error();
auto result = inspector()->GetUniformBufferResourceBindings("ubo_func"); auto result = inspector()->GetUniformBufferResourceBindings("ub_func");
std::string error = inspector()->error(); std::string error = inspector()->error();
EXPECT_TRUE(error.find("not an entry point") != std::string::npos); EXPECT_TRUE(error.find("not an entry point") != std::string::npos);
} }
@ -833,13 +833,13 @@ TEST_F(InspectorGetUniformBufferResourceBindings, MissingBlockDeco) {
auto foo_type = auto foo_type =
std::make_unique<ast::type::StructType>("foo_type", std::move(str)); std::make_unique<ast::type::StructType>("foo_type", std::move(str));
AddUBO("foo_ubo", foo_type.get(), 0, 0); AddUniformBuffer("foo_ub", foo_type.get(), 0, 0);
auto ubo_func = auto ub_func = MakeUniformBufferReferenceBodyFunction("ub_func", "foo_ub",
MakeUBOReferenceBodyFunction("ubo_func", "foo_ubo", {{0, i32_type()}}); {{0, i32_type()}});
mod()->AddFunction(std::move(ubo_func)); mod()->AddFunction(std::move(ub_func));
auto ep_func = MakeCallerBodyFunction("ep_func", "ubo_func"); auto ep_func = MakeCallerBodyFunction("ep_func", "ub_func");
ep_func->add_decoration( ep_func->add_decoration(
std::make_unique<ast::StageDecoration>(ast::PipelineStage::kVertex)); std::make_unique<ast::StageDecoration>(ast::PipelineStage::kVertex));
mod()->AddFunction(std::move(ep_func)); mod()->AddFunction(std::move(ep_func));
@ -852,14 +852,14 @@ TEST_F(InspectorGetUniformBufferResourceBindings, MissingBlockDeco) {
} }
TEST_F(InspectorGetUniformBufferResourceBindings, Simple) { TEST_F(InspectorGetUniformBufferResourceBindings, Simple) {
auto foo_type = MakeUBOStructType("foo_type", {{i32_type(), 0}}); auto foo_type = MakeUniformBufferStructType("foo_type", {{i32_type(), 0}});
AddUBO("foo_ubo", foo_type.get(), 0, 0); AddUniformBuffer("foo_ub", foo_type.get(), 0, 0);
auto ubo_func = auto ub_func = MakeUniformBufferReferenceBodyFunction("ub_func", "foo_ub",
MakeUBOReferenceBodyFunction("ubo_func", "foo_ubo", {{0, i32_type()}}); {{0, i32_type()}});
mod()->AddFunction(std::move(ubo_func)); mod()->AddFunction(std::move(ub_func));
auto ep_func = MakeCallerBodyFunction("ep_func", "ubo_func"); auto ep_func = MakeCallerBodyFunction("ep_func", "ub_func");
ep_func->add_decoration( ep_func->add_decoration(
std::make_unique<ast::StageDecoration>(ast::PipelineStage::kVertex)); std::make_unique<ast::StageDecoration>(ast::PipelineStage::kVertex));
mod()->AddFunction(std::move(ep_func)); mod()->AddFunction(std::move(ep_func));
@ -876,16 +876,15 @@ TEST_F(InspectorGetUniformBufferResourceBindings, Simple) {
} }
TEST_F(InspectorGetUniformBufferResourceBindings, MultipleMembers) { TEST_F(InspectorGetUniformBufferResourceBindings, MultipleMembers) {
auto foo_type = MakeUBOStructType( auto foo_type = MakeUniformBufferStructType(
"foo_type", {{i32_type(), 0}, {u32_type(), 4}, {f32_type(), 8}}); "foo_type", {{i32_type(), 0}, {u32_type(), 4}, {f32_type(), 8}});
AddUBO("foo_ubo", foo_type.get(), 0, 0); AddUniformBuffer("foo_ub", foo_type.get(), 0, 0);
auto ubo_func = MakeUBOReferenceBodyFunction( auto ub_func = MakeUniformBufferReferenceBodyFunction(
"ubo_func", "foo_ubo", "ub_func", "foo_ub", {{0, i32_type()}, {1, u32_type()}, {2, f32_type()}});
{{0, i32_type()}, {1, u32_type()}, {2, f32_type()}}); mod()->AddFunction(std::move(ub_func));
mod()->AddFunction(std::move(ubo_func));
auto ep_func = MakeCallerBodyFunction("ep_func", "ubo_func"); auto ep_func = MakeCallerBodyFunction("ep_func", "ub_func");
ep_func->add_decoration( ep_func->add_decoration(
std::make_unique<ast::StageDecoration>(ast::PipelineStage::kVertex)); std::make_unique<ast::StageDecoration>(ast::PipelineStage::kVertex));
mod()->AddFunction(std::move(ep_func)); mod()->AddFunction(std::move(ep_func));
@ -901,23 +900,23 @@ TEST_F(InspectorGetUniformBufferResourceBindings, MultipleMembers) {
EXPECT_EQ(12u, result[0].min_buffer_binding_size); EXPECT_EQ(12u, result[0].min_buffer_binding_size);
} }
TEST_F(InspectorGetUniformBufferResourceBindings, MultipleUBOs) { TEST_F(InspectorGetUniformBufferResourceBindings, MultipleUniformBufferS) {
auto ubo_type = MakeUBOStructType( auto ub_type = MakeUniformBufferStructType(
"ubo_type", {{i32_type(), 0}, {u32_type(), 4}, {f32_type(), 8}}); "ub_type", {{i32_type(), 0}, {u32_type(), 4}, {f32_type(), 8}});
AddUBO("ubo_foo", ubo_type.get(), 0, 0); AddUniformBuffer("ub_foo", ub_type.get(), 0, 0);
AddUBO("ubo_bar", ubo_type.get(), 0, 1); AddUniformBuffer("ub_bar", ub_type.get(), 0, 1);
AddUBO("ubo_baz", ubo_type.get(), 2, 0); AddUniformBuffer("ub_baz", ub_type.get(), 2, 0);
auto AddReferenceFunc = [this](const std::string& func_name, auto AddReferenceFunc = [this](const std::string& func_name,
const std::string& var_name) { const std::string& var_name) {
auto ubo_func = MakeUBOReferenceBodyFunction( auto ub_func = MakeUniformBufferReferenceBodyFunction(
func_name, var_name, func_name, var_name,
{{0, i32_type()}, {1, u32_type()}, {2, f32_type()}}); {{0, i32_type()}, {1, u32_type()}, {2, f32_type()}});
mod()->AddFunction(std::move(ubo_func)); mod()->AddFunction(std::move(ub_func));
}; };
AddReferenceFunc("ubo_foo_func", "ubo_foo"); AddReferenceFunc("ub_foo_func", "ub_foo");
AddReferenceFunc("ubo_bar_func", "ubo_bar"); AddReferenceFunc("ub_bar_func", "ub_bar");
AddReferenceFunc("ubo_baz_func", "ubo_baz"); AddReferenceFunc("ub_baz_func", "ub_baz");
auto AddFuncCall = [](ast::BlockStatement* body, const std::string& callee) { auto AddFuncCall = [](ast::BlockStatement* body, const std::string& callee) {
auto ident_expr = std::make_unique<ast::IdentifierExpression>(callee); auto ident_expr = std::make_unique<ast::IdentifierExpression>(callee);
@ -927,9 +926,9 @@ TEST_F(InspectorGetUniformBufferResourceBindings, MultipleUBOs) {
}; };
auto body = std::make_unique<ast::BlockStatement>(); auto body = std::make_unique<ast::BlockStatement>();
AddFuncCall(body.get(), "ubo_foo_func"); AddFuncCall(body.get(), "ub_foo_func");
AddFuncCall(body.get(), "ubo_bar_func"); AddFuncCall(body.get(), "ub_bar_func");
AddFuncCall(body.get(), "ubo_baz_func"); AddFuncCall(body.get(), "ub_baz_func");
body->append(std::make_unique<ast::ReturnStatement>()); body->append(std::make_unique<ast::ReturnStatement>());
std::unique_ptr<ast::Function> func = std::make_unique<ast::Function>( std::unique_ptr<ast::Function> func = std::make_unique<ast::Function>(
@ -960,15 +959,15 @@ TEST_F(InspectorGetUniformBufferResourceBindings, MultipleUBOs) {
} }
TEST_F(InspectorGetUniformBufferResourceBindings, ContainingArray) { TEST_F(InspectorGetUniformBufferResourceBindings, ContainingArray) {
auto foo_type = auto foo_type = MakeUniformBufferStructType(
MakeUBOStructType("foo_type", {{i32_type(), 0}, {u32_array_type(4), 4}}); "foo_type", {{i32_type(), 0}, {u32_array_type(4), 4}});
AddUBO("foo_ubo", foo_type.get(), 0, 0); AddUniformBuffer("foo_ub", foo_type.get(), 0, 0);
auto ubo_func = auto ub_func = MakeUniformBufferReferenceBodyFunction("ub_func", "foo_ub",
MakeUBOReferenceBodyFunction("ubo_func", "foo_ubo", {{0, i32_type()}}); {{0, i32_type()}});
mod()->AddFunction(std::move(ubo_func)); mod()->AddFunction(std::move(ub_func));
auto ep_func = MakeCallerBodyFunction("ep_func", "ubo_func"); auto ep_func = MakeCallerBodyFunction("ep_func", "ub_func");
ep_func->add_decoration( ep_func->add_decoration(
std::make_unique<ast::StageDecoration>(ast::PipelineStage::kVertex)); std::make_unique<ast::StageDecoration>(ast::PipelineStage::kVertex));
mod()->AddFunction(std::move(ep_func)); mod()->AddFunction(std::move(ep_func));