Page 1 of 1

"default" on Ogre2.1/D3D11?

Posted: Tue Sep 19, 2017 20:22
by mmixLinus
Hi, On Win x64, I get

Code: Select all

Cannot compile D3D11 high-level shader __cegui_internal_texture_ps__ Errors:
(11,13-31): error X3523: DX9-style intrinsics are disabled when not in dx9 compatibility mode.
and

Code: Select all

High-level program __cegui_internal_colour_ps__ encountered an error during loading and is thus not supported.
OGRE EXCEPTION(-2147467259:RenderingAPIException): Cannot compile D3D11 high-level shader __cegui_internal_colour_ps__ Errors:
(9,27-33): error X4502: invalid ps_5_0 output semantic 'COLOR'
at startup. Do I need to add dx9 compatibility mode to the microcode compiler, or is the Cegui ("default" branch) shader not ready for this yet? Or something else? :) Maybe go for OpenGl3+..?

This happens when constructing the OgreRenderer, specifically initialiseShaders();

<3 /mmixLinus

Re: "default" on Ogre2.1/D3D11?

Posted: Tue Sep 19, 2017 20:29
by Ident
Cegui version? Ogre version?

Re: "default" on Ogre2.1/D3D11?

Posted: Wed Sep 20, 2017 08:02
by mmixLinus
The title says it all :)
And I'll post the log file too (soon) :oops:

CEGUI branch default (= 1.0) "latest" with OgreRenderer.
Ogre 2.1 "latest" with D3D11 renderer

Re: "default" on Ogre2.1/D3D11?

Posted: Wed Sep 20, 2017 14:54
by mmixLinus
Oh yes, now I remember why I didn't post the log..

Code: Select all

20/09/2017 16:49:33 (Std)    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
20/09/2017 16:49:33 (Std)    +                     Crazy Eddie's GUI System - Event log                    +
20/09/2017 16:49:33 (Std)    +                          (http://www.cegui.org.uk/)                         +
20/09/2017 16:49:33 (Std)    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

20/09/2017 16:49:33 (Std)    CEGUI::Logger Singleton created. (0000000005CD5730)
20/09/2017 16:49:33 (Std)    
20/09/2017 16:49:33 (Std)    ********************************************************************************
20/09/2017 16:49:33 (Std)    * Important:                                                                   *
20/09/2017 16:49:33 (Std)    *     To get support at the CEGUI forums, you must post _at least_ the section *
20/09/2017 16:49:33 (Std)    *     of this log file indicated below.  Failure to do this will result in no  *
20/09/2017 16:49:33 (Std)    *     support being given; please do not waste our time.                       *
20/09/2017 16:49:33 (Std)    ********************************************************************************
20/09/2017 16:49:33 (Std)    ********************************************************************************
20/09/2017 16:49:33 (Std)    * -------- START OF ESSENTIAL SECTION TO BE POSTED ON THE FORUM       -------- *
20/09/2017 16:49:33 (Std)    ********************************************************************************
20/09/2017 16:49:33 (Std)    ---- Version: 9999.0.0 (Build: Sep 19 2017 Debug Microsoft Windows MSVC++ 12.0 (2013) 64 bit) ----
20/09/2017 16:49:33 (Std)    ---- Renderer module is: CEGUI::OgreRenderer - OGRE based 3rd generation renderer module with Ogre::Compositor2 enabled. ----
The problem arises quite early, in OgreRenderer::constructor_impl() - so that's all there is.

Re: "default" on Ogre2.1/D3D11?

Posted: Wed Sep 20, 2017 14:56
by mmixLinus
Meh,.. I was running Ogre v2.1, but not latest it turns out. I'll respin and get back.

Re: "default" on Ogre2.1/D3D11?

Posted: Wed Sep 20, 2017 18:05
by mmixLinus
No difference with latest Ogre 2.1.
CEGUI's pixel shader

Code: Select all

uniform float alphaPercentage;
struct VS_OUT
{
   float4 position : POSITION;
   float4 colour : COLOR;
   float2 uv : TexCoord0;
};
float4 main(float4 colour : COLOR, float2 uv : TexCoord0,                uniform sampler2D texture0 : TEXUNIT0) : COLOR
{
   colour = tex2D(texture0, uv) * colour;
   colour.a *= alphaPercentage;
   return colour;
}
is part of the problem. In the OgreShaderWrapper constructor, in the code

Code: Select all

    const Ogre::GpuConstantDefinitionMap& pixel_map =
        d_pixelShader->getConstantDefinitions().map;

    Ogre::GpuConstantDefinitionMap::const_iterator target2 =
        pixel_map.find("alphaPercentage");
pixel_map is empty, so the find() fails, and OgreShaderWrapper() subsequently throws.

Re: "default" on Ogre2.1/D3D11?

Posted: Wed Sep 20, 2017 22:17
by Ident
Do you mind trying with CEGUI v0-8 ? Just trying for now, because I know that different ppl made PRs on those two branches and support for Ogre may differ at this point.

Re: "default" on Ogre2.1/D3D11?

Posted: Thu Sep 21, 2017 08:11
by mmixLinus
I was initially on v0-8 (latest) but having problems, so I decided to try with the default branch. Actually, v0-8 got much further, and that problem was more related to parsing XML resources. I will give v0-8 another shot. For "default", I'll also see if I can select a different Shader Model for the D3D11 compiler, and see if I get further. :)

Re: "default" on Ogre2.1/D3D11?

Posted: Thu Sep 21, 2017 17:17
by Ident
Ogre 2.0 and Ogre 2.1 support is entirely based on user contributions :)

Re: "default" on Ogre2.1/D3D11?

Posted: Thu Apr 05, 2018 05:43
by crancran
FWIW, I've been working on support for OGRE 2.2 in CEGUI as of late and ran into this very issue. The fix is actually quite trivial. It simply involves making 2 changes to the HLSL shaders in the Ogre renderer module's Shaders.inl file.

1. PixelShaderColoured_HLSL

Code: Select all

"uniform float alphaPercentage;\n"
"\n"
"struct VS_OUT\n"
"{\n"
"   float4 position : POSITION;\n"
"   float4 colour : COLOR;\n"
"};\n"
"\n"
"float4 main(VS_OUT input) : SV_Target\n"
"{\n"
"   float4 colour = input.colour;\n"
"   colour.a *= alphaPercentage;\n"
"   return colour;\n"
"}\n"
"\n"


2. PixelShaderTextured_HLSL
In this shader, we want to change the text to read the following:

Code: Select all

"SamplerState textureSamplerState;\n"
"uniform float alphaPercentage;\n"
"struct VS_OUT\n"
"{\n"
"   float4 position : POSITION;\n"
"   float4 colour : COLOR;\n"
"   float2 uv : TexCoord0;\n"
"};\n"
"\n"
"float4 main(float4 colour : COLOR, float2 uv : TexCoord0, "
"               uniform Texture2D texture0 : TEXUNIT0) : SV_Target\n"
"{\n"
"   colour = texture0.Sample(textureSamplerState, uv) * colour;\n"
"   colour.a *= alphaPercentage;\n"
"   return colour;\n"
"}\n"
"\n"

After making these changes, the OP's original shader compiler problems go away and CEGUI bootstraps just fine. I'm posting this here until I can get the fix into the repo in case others are intersted in patching the OGRE renderer to work with DX11 in the short-term.

Re: "default" on Ogre2.1/D3D11?

Posted: Thu Apr 05, 2018 06:13
by Ident
Thanks. And you are correct, having this in the repo should definitely be the goal.

Re: "default" on Ogre2.1/D3D11?

Posted: Thu Apr 05, 2018 06:17
by crancran
I have sent in the PR, found here.