@@ -2200,6 +2200,53 @@ TEST_P(EntityTest, RuntimeEffect) {
22002200 ASSERT_TRUE (OpenPlaygroundHere (callback));
22012201}
22022202
2203+ TEST_P (EntityTest, RuntimeEffectCanSuccessfullyRender) {
2204+ auto runtime_stages =
2205+ OpenAssetAsRuntimeStage (" runtime_stage_example.frag.iplr" );
2206+ auto runtime_stage =
2207+ runtime_stages[PlaygroundBackendToRuntimeStageBackend (GetBackend ())];
2208+ ASSERT_TRUE (runtime_stage);
2209+ ASSERT_TRUE (runtime_stage->IsDirty ());
2210+
2211+ auto contents = std::make_shared<RuntimeEffectContents>();
2212+ contents->SetGeometry (Geometry::MakeCover ());
2213+
2214+ contents->SetRuntimeStage (runtime_stage);
2215+
2216+ struct FragUniforms {
2217+ Vector2 iResolution;
2218+ Scalar iTime;
2219+ } frag_uniforms = {
2220+ .iResolution = Vector2 (GetWindowSize ().width , GetWindowSize ().height ),
2221+ .iTime = static_cast <Scalar>(GetSecondsElapsed ()),
2222+ };
2223+ auto uniform_data = std::make_shared<std::vector<uint8_t >>();
2224+ uniform_data->resize (sizeof (FragUniforms));
2225+ memcpy (uniform_data->data (), &frag_uniforms, sizeof (FragUniforms));
2226+ contents->SetUniformData (uniform_data);
2227+
2228+ Entity entity;
2229+ entity.SetContents (contents);
2230+
2231+ // Create a render target with a depth-stencil, similar to how EntityPass
2232+ // does.
2233+ RenderTarget target = RenderTarget::CreateOffscreenMSAA (
2234+ *GetContext (), *GetContentContext ()->GetRenderTargetCache (),
2235+ {GetWindowSize ().width , GetWindowSize ().height }, 1 ,
2236+ " RuntimeEffect Texture" );
2237+ testing::MockRenderPass pass (GetContext (), target);
2238+
2239+ ASSERT_TRUE (contents->Render (*GetContentContext (), entity, pass));
2240+ ASSERT_EQ (pass.GetCommands ().size (), 1u );
2241+ const auto & command = pass.GetCommands ()[0 ];
2242+ ASSERT_TRUE (command.pipeline ->GetDescriptor ()
2243+ .GetDepthStencilAttachmentDescriptor ()
2244+ .has_value ());
2245+ ASSERT_TRUE (command.pipeline ->GetDescriptor ()
2246+ .GetFrontStencilAttachmentDescriptor ()
2247+ .has_value ());
2248+ }
2249+
22032250TEST_P (EntityTest, RuntimeEffectSetsRightSizeWhenUniformIsStruct) {
22042251 if (GetBackend () != PlaygroundBackend::kVulkan ) {
22052252 GTEST_SKIP () << " Test only applies to Vulkan" ;
0 commit comments