47 flatbuffers::FlatBufferBuilder builder;
48 fb::RuntimeStagesBuilder stages_builder(builder);
49 stages_builder.add_format_version(0);
50 auto stages = stages_builder.Finish();
51 builder.Finish(stages, fb::RuntimeStagesIdentifier());
52 auto mapping = std::make_shared<fml::NonOwnedMapping>(
53 builder.GetBufferPointer(), builder.GetSize());
55 EXPECT_FALSE(runtime_stages.ok());
56 EXPECT_EQ(runtime_stages.status().code(), absl::StatusCode::kInvalidArgument);
76 const std::shared_ptr<fml::Mapping> fixture =
78 "all_supported_uniforms.frag.iplr");
80 ASSERT_GT(fixture->GetSize(), 0u);
82 ABSL_ASSERT_OK(stages);
87 switch (GetBackend()) {
91 ASSERT_EQ(stage->GetUniforms().size(), 14u);
94 auto uni = stage->GetUniform(
"uFloat");
95 ASSERT_NE(uni,
nullptr);
96 EXPECT_EQ(uni->dimensions.rows, 1u);
97 EXPECT_EQ(uni->dimensions.cols, 1u);
98 EXPECT_EQ(uni->location, 0u);
100 EXPECT_TRUE(uni->padding_layout.empty());
104 auto uni = stage->GetUniform(
"uVec2");
105 ASSERT_NE(uni,
nullptr);
106 EXPECT_EQ(uni->dimensions.rows, 2u);
107 EXPECT_EQ(uni->dimensions.cols, 1u);
108 EXPECT_EQ(uni->location, 1u);
110 EXPECT_TRUE(uni->padding_layout.empty());
114 auto uni = stage->GetUniform(
"uVec3");
115 ASSERT_NE(uni,
nullptr);
116 EXPECT_EQ(uni->dimensions.rows, 3u);
117 EXPECT_EQ(uni->dimensions.cols, 1u);
118 EXPECT_EQ(uni->location, 2u);
120 auto padding = uni->padding_layout;
133 auto uni = stage->GetUniform(
"uVec4");
134 ASSERT_NE(uni,
nullptr);
135 EXPECT_EQ(uni->dimensions.rows, 4u);
136 EXPECT_EQ(uni->dimensions.cols, 1u);
137 EXPECT_EQ(uni->location, 3u);
139 EXPECT_TRUE(uni->padding_layout.empty());
143 auto uni = stage->GetUniform(
"uMat2");
144 ASSERT_NE(uni,
nullptr);
145 EXPECT_EQ(uni->dimensions.rows, 2u);
146 EXPECT_EQ(uni->dimensions.cols, 2u);
147 EXPECT_EQ(uni->location, 4u);
149 EXPECT_TRUE(uni->padding_layout.empty());
153 auto uni = stage->GetUniform(
"uMat3");
154 ASSERT_NE(uni,
nullptr);
155 EXPECT_EQ(uni->dimensions.rows, 3u);
156 EXPECT_EQ(uni->dimensions.cols, 3u);
157 EXPECT_EQ(uni->location, 5u);
162 auto uni = stage->GetUniform(
"uMat4");
163 ASSERT_NE(uni,
nullptr);
164 EXPECT_EQ(uni->dimensions.rows, 4u);
165 EXPECT_EQ(uni->dimensions.cols, 4u);
166 EXPECT_EQ(uni->location, 6u);
168 EXPECT_TRUE(uni->padding_layout.empty());
172 auto uni = stage->GetUniform(
"uFloatArray");
173 ASSERT_NE(uni,
nullptr);
174 EXPECT_EQ(uni->dimensions.rows, 1u);
175 EXPECT_EQ(uni->dimensions.cols, 1u);
176 EXPECT_EQ(uni->location, 7u);
178 EXPECT_TRUE(uni->padding_layout.empty());
181 auto uni = stage->GetUniform(
"uVec2Array");
182 ASSERT_NE(uni,
nullptr);
183 EXPECT_EQ(uni->dimensions.rows, 2u);
184 EXPECT_EQ(uni->dimensions.cols, 1u);
185 EXPECT_EQ(uni->location, 9u);
187 EXPECT_TRUE(uni->padding_layout.empty());
191 auto uni = stage->GetUniform(
"uVec3Array");
192 ASSERT_NE(uni,
nullptr);
193 EXPECT_EQ(uni->dimensions.rows, 3u);
194 EXPECT_EQ(uni->dimensions.cols, 1u);
195 EXPECT_EQ(uni->location, 11u);
200 auto uni = stage->GetUniform(
"uVec4Array");
201 ASSERT_NE(uni,
nullptr);
202 EXPECT_EQ(uni->dimensions.rows, 4u);
203 EXPECT_EQ(uni->dimensions.cols, 1u);
204 EXPECT_EQ(uni->location, 13u);
206 EXPECT_TRUE(uni->padding_layout.empty());
210 auto uni = stage->GetUniform(
"uMat2Array");
211 ASSERT_NE(uni,
nullptr);
212 EXPECT_EQ(uni->dimensions.rows, 2u);
213 EXPECT_EQ(uni->dimensions.cols, 2u);
214 EXPECT_EQ(uni->location, 15u);
216 EXPECT_TRUE(uni->padding_layout.empty());
220 auto uni = stage->GetUniform(
"uMat3Array");
221 ASSERT_NE(uni,
nullptr);
222 EXPECT_EQ(uni->dimensions.rows, 3u);
223 EXPECT_EQ(uni->dimensions.cols, 3u);
224 EXPECT_EQ(uni->location, 17u);
229 auto uni = stage->GetUniform(
"uMat4Array");
230 ASSERT_NE(uni,
nullptr);
231 EXPECT_EQ(uni->dimensions.rows, 4u);
232 EXPECT_EQ(uni->dimensions.cols, 4u);
233 EXPECT_EQ(uni->location, 19u);
235 EXPECT_TRUE(uni->padding_layout.empty());
240 EXPECT_EQ(stage->GetUniforms().size(), 1u);
248 std::vector<RuntimePaddingType> layout(uni->
GetGPUSize() /
sizeof(
float),
310 EXPECT_THAT(uni->
padding_layout, ::testing::ElementsAreArray(layout));
312 std::vector<std::pair<std::string, unsigned int>> expected_uniforms = {
313 {
"uFloat", 4}, {
"uVec2", 8}, {
"uVec3", 12},
314 {
"uVec4", 16}, {
"uMat2", 16}, {
"uMat3", 36},
315 {
"uMat4", 64}, {
"uFloatArray", 8}, {
"uVec2Array", 16},
316 {
"uVec3Array", 24}, {
"uVec4Array", 32}, {
"uMat2Array", 32},
317 {
"uMat3Array", 72}, {
"uMat4Array", 128}};
319 ASSERT_EQ(uni->
struct_fields.size(), expected_uniforms.size());
321 for (
size_t i = 0;
i < expected_uniforms.size(); ++
i) {
323 const auto& expected = expected_uniforms[
i];
325 EXPECT_EQ(element.name, expected.first) <<
"index: " <<
i;
326 EXPECT_EQ(element.byte_size, expected.second) <<
"index: " <<
i;
388 const std::shared_ptr<fml::Mapping> fixture =
390 ASSERT_TRUE(fixture);
391 ASSERT_GT(fixture->GetSize(), 0u);
393 ABSL_ASSERT_OK(stages);
397 std::promise<bool> registration;
398 auto future = registration.get_future();
399 auto library = GetContext()->GetShaderLibrary();
400 library->RegisterFunction(
401 stage->GetEntrypoint(),
403 stage->GetCodeMapping(),
405 reg.set_value(result);
407 ASSERT_TRUE(future.get());
425 auto stages_result = OpenAssetAsRuntimeStage(
"ink_sparkle.frag.iplr");
426 ABSL_ASSERT_OK(stages_result);
432 ASSERT_NE(stage,
nullptr);
433 ASSERT_TRUE(RegisterStage(*stage));
434 auto library = GetContext()->GetShaderLibrary();
435 using VS = RuntimeEffectVertexShader;
437 desc.
SetLabel(
"Runtime Stage InkSparkle");
442 auto vertex_descriptor = std::make_shared<VertexDescriptor>();
443 vertex_descriptor->SetStageInputs(VS::kAllShaderStageInputs,
444 VS::kInterleavedBufferLayout);
446 std::array<DescriptorSetLayout, 2> descriptor_set_layouts = {
447 VS::kDescriptorSetLayouts[0],
454 vertex_descriptor->RegisterDescriptorSetLayouts(descriptor_set_layouts);
458 color0.
format = GetContext()->GetCapabilities()->GetDefaultColorFormat();
463 const auto stencil_fmt =
464 GetContext()->GetCapabilities()->GetDefaultStencilFormat();
466 auto pipeline = GetContext()->GetPipelineLibrary()->GetPipeline(desc).Get();
467 ASSERT_NE(pipeline,
nullptr);
Vector2 padding
The halo padding in source space.