[1.12.10] Compositor fails to resolve global_scope texture reference across chains Topic is solved

Problems building or running the engine, queries about how to use features etc.
Post Reply
mgiordano
Gnoblar
Posts: 17
Joined: Tue Jan 10, 2012 8:49 pm
x 2

[1.12.10] Compositor fails to resolve global_scope texture reference across chains

Post by mgiordano »

Ogre Version: 1.12.10
Operating System: Windows 10
Render System: DX11

There appears to be a logic error in CompositorInstance::resolveTexReference when using a texture_ref with a globabl_scope texture from another compositor chain. Referring to the code listed below, the comment on the first if statement says "Try chain first". However, if the compositor referenced in refCompName is not found on the current chain, Ogre throws an exception, instead of continuing on to try the global search.

For example, I currently have one compositor chain with Compositor A that creates a texture with global_scope. I also have a second independent compositor chain with Compositor B that contains a texture_ref of the texture created by Compositor A. With the current code, it is not possible to resolve the texture reference, because Compositor A does not exist on the chain that holds Compositor B.

The manual seems to indicate it is OK to share global_scope textures across different compositor chains. Am I misunderstanding how this should be used or is this a bug?

Thanks!

Code: Select all

CompositionTechnique::TextureDefinition*
CompositorInstance::resolveTexReference(const CompositionTechnique::TextureDefinition* texDef)
{
    //This TextureDefinition is reference.
    //Since referenced TD's have no info except name we have to find original TD

    CompositionTechnique::TextureDefinition* refTexDef = 0;

    //Try chain first
    if(mChain)
    {
        CompositorInstance* refCompInst = mChain->getCompositor(texDef->refCompName);
        if(!refCompInst)
            OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, "Referencing non-existent compositor");

        refTexDef = refCompInst->getCompositor()->getSupportedTechnique(
            refCompInst->getScheme())->getTextureDefinition(texDef->refTexName);
    }

    if(!refTexDef)
    {
        //Still NULL. Try global search.
        const CompositorPtr &refComp = CompositorManager::getSingleton().getByName(texDef->refCompName);
        if(refComp)
        {
            refTexDef = refComp->getSupportedTechnique()->getTextureDefinition(texDef->refTexName);
        }
    }

    if(!refTexDef)
    {
        OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, "Referencing non-existent compositor texture");
    }

    if (refTexDef->scope == CompositionTechnique::TS_LOCAL)
        OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS,
                    "Referenced texture '" + texDef->refTexName + "' has only local scope");

    return refTexDef;
}
paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: [1.12.10] Compositor fails to resolve global_scope texture reference across chains

Post by paroj »

mgiordano wrote: Fri Feb 05, 2021 2:15 am The manual seems to indicate it is OK to share global_scope textures across different compositor chains.
I think this is the whole point of global_scope. This is a bug.

Will be fixed with https://github.com/OGRECave/ogre/pull/1879
mgiordano
Gnoblar
Posts: 17
Joined: Tue Jan 10, 2012 8:49 pm
x 2

Re: [1.12.10] Compositor fails to resolve global_scope texture reference across chains

Post by mgiordano »

Thank you @paroj for your rapid response! Keep up the great work!
Post Reply