Hi, after switching to Ogre 2.3 and trying to enable Vulkan as render system I encountered the following issue :
OGRE EXCEPTION(1:InvalidStateException): Texture NavBallTexture is not in ResourceLayout::Texture nor RenderTargetReadOnly. Did you forget to expose it to compositor? Currently rendering to target: RenderWindow in VulkanRenderSystem::checkTextureLayout at D:\dev\ogre-next\RenderSystems\Vulkan\src\OgreVulkanRenderSystem.cpp (line 1541)
I have a Colibri widget using this material :
Code: Select all
hlms NavBall_UI unlit
{
#diffuse_map is set at runtime
depth_check off
scene_blend alpha_blend
}
The texture is created and set when the widget is initialised (Colibri::Renderable::_initialize()):
Code: Select all
//allocate texture we'll render on
Ogre::Root *root = Ogre::Root::getSingletonPtr();
Ogre::TextureGpuManager *textureManager = root->getRenderSystem()->getTextureGpuManager();
_texture = textureManager->createTexture(
"NavBallTexture",
Ogre::GpuPageOutStrategy::Discard, Ogre::TextureFlags::RenderToTexture, Ogre::TextureTypes::Type2D );
_texture->setResolution(512, 512);
_texture->setPixelFormat(Ogre::PFG_RGBA32_FLOAT);
_texture->scheduleTransitionTo(Ogre::GpuResidency::Resident);
Ogre::SceneManager *sceneManager = m_manager->getOgreSceneManager();
_camera = sceneManager->createCamera("NavBallCamera");
_camera->setNearClipDistance(0.01f);
_camera->setProjectionType(Ogre::PT_ORTHOGRAPHIC);
_camera->setOrthoWindow(2.5f, 2.5f);
Ogre::CompositorManager2 *compositorManager = root->getCompositorManager2();
_workspace = compositorManager->addWorkspace( sceneManager, _texture,
_camera, "NavBallWorkspace", true );
// Find material and assign RTT texture to it
Ogre::Hlms *hlms = root->getHlmsManager()->getHlms( Ogre::HLMS_UNLIT );
Ogre::HlmsDatablock *datablock = hlms->getDatablock( "NavBall_UI" );
assert( dynamic_cast<Ogre::HlmsUnlitDatablock *>( datablock ) );
Ogre::HlmsUnlitDatablock *unlitDatablock = dynamic_cast<Ogre::HlmsUnlitDatablock *>(datablock);
unlitDatablock->setTexture(0u, _texture); // Set texture
And the compositor :
Code: Select all
compositor_node NavBallNode
{
in 0 rt_renderwindow
target rt_renderwindow
{
pass clear
{
colour_value 0.0 0.0 0.0 0.0
}
pass render_scene
{
rq_first 21
rq_last 22
}
}
}
workspace NavBallWorkspace
{
//Connect RenderWindow to FinalComposition's input channel #0
connect_output NavBallNode 0
}
This topic seems to cover the issue somehow but I couldn't fix my problem :/
From my understanding I can't use the same texture as rendertarget and texture for the widget or at least need to put appropriate barriers, but how in the script?
I read in another topic that I could render the scene in a local texture then copy it in a render_quad pass, I tried that but the issue stayed exactly the same.
I also read about adding a listener and copying the texture after the last pass, but that seems overkill to bring back the texture, copy it in memory then resend it.
Which approach is the best for that please? What must I add in the scripts to make it work with Vulkan, or should I code everything instead of using scripts? Thanks