RTSS/DX11: error X3025: out parameters require l-value arguments

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
ManVsOgre
Gnoblar
Posts: 7
Joined: Thu Jan 18, 2018 3:58 pm

RTSS/DX11: error X3025: out parameters require l-value arguments

Post by ManVsOgre »

Hello Folks,

i currently porting my code from Ogre 1.9 to Ogre 1.10.10. If I try to create a shader with RTSS in DX11
and setting both Options setLightingEnabled(true) and setVertexColourTracking(Ogre::TVC_DIFFUSE) in my Pass,
i am getting this error.

From Ogre.log

Code: Select all

Ogre: High-level program '612cf422ed8f582b7e98591a476c3396_VS' is not supported: Cannot compile D3D11 high-level shader 612cf422ed8f582b7e98591a476c3396_VS Errors:
(58,2): warning X3206: 'FFP_Modulate': implicit truncation of vector type
(58,2): warning X3206: 'FFP_Modulate': implicit truncation of vector type
(58,2): error X3025: out parameters require l-value arguments (given argument is implicitly const, such as a global)

Code: Select all

//-----------------------------------------------------------------------------
// Program Type: Vertex shader
// Language: hlsl
// Created by Ogre RT Shader Generator. All rights reserved.
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
//                         PROGRAM DEPENDENCIES
//-----------------------------------------------------------------------------
#include "FFPLib_Transform.hlsl"
#include "FFPLib_Common.hlsl"
#include "FFPLib_Lighting.hlsl"
#include "FFPLib_Texturing.hlsl"
#include "FFPLib_Fog.hlsl"

//-----------------------------------------------------------------------------
//                         GLOBAL PARAMETERS
//-----------------------------------------------------------------------------

float4x4	worldviewproj_matrix;
float4x4	inverse_transpose_worldview_matrix;
float4	ambient_light_colour;
float4	surface_ambient_colour;
float4	surface_specular_colour;
float4	surface_emissive_colour;
float4	derived_scene_colour;
float	surface_shininess;
float4	light_position_view_space0;
float4	light_diffuse1;
float4	gFogParams2;

//-----------------------------------------------------------------------------
// Function Name: main
// Function Desc: Vertex Program Entry point
//-----------------------------------------------------------------------------
void main
	(
	 in float4	iPos_0 : POSITION, 
	 in float4	iColor_0 : COLOR, 
	 in float3	iNormal_0 : NORMAL, 
	 out float4	oPos_0 : SV_Position, 
	 out float4	oColor_0 : COLOR, 
	 out float	oTexcoord1_0 : TEXCOORD0
	)
{
	float4	lLocalParam_0;

	FFP_Transform(worldviewproj_matrix, iPos_0, oPos_0);

	FFP_Assign(iColor_0, oColor_0);

	FFP_Construct(0.0, 0.0, 0.0, 0.0, lLocalParam_0);

	FFP_Modulate(ambient_light_colour, iColor_0, oColor_0);

	FFP_Add(surface_emissive_colour, oColor_0, oColor_0);

	FFP_Modulate(iColor_0.xyz, light_diffuse1.xyz, light_diffuse1.xyz);

	FFP_Light_Directional_Diffuse(inverse_transpose_worldview_matrix, iNormal_0, light_position_view_space0.xyz, light_diffuse1.xyz, oColor_0.xyz, oColor_0.xyz);

	FFP_VertexFog_Exp(worldviewproj_matrix, iPos_0, gFogParams2, oTexcoord1_0);
}
C++ code

Code: Select all

//create material...................
  Ogre::MaterialManager& MatMgr = Ogre::MaterialManager::getSingleton();
  auto MatResult = MatMgr.createOrRetrieve(MaterialName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
  if(MatResult.second)
  {
    Ogre::MaterialPtr MaterialBasis = Ogre::static_pointer_cast<Ogre::Material>(MatResult.first);
      MaterialBasis->setCullingMode(Ogre::CULL_NONE);
      MaterialBasis->compile();
     Ogre::Pass* PassSurface = MaterialBasis->getBestTechnique()->getPass(0);
      if(PassSurface)
      {
        // PassSurface->setLightingEnabled(false); // ok
        // PassSurface->setVertexColourTracking(Ogre::TVC_DIFFUSE); // ok
        //or 
        // PassSurface->setLightingEnabled(true); // ok
        // PassSurface->setVertexColourTracking(Ogre::TVC_AMBIENT); // ok
        // but not........
         PassSurface->setLightingEnabled(true); // crash 
         PassSurface->setVertexColourTracking(Ogre::TVC_DIFFUSE); // crash
      }
      MaterialBasis->load();
    
 //now make the shader................
 Ogre::RTShader::ShaderGenerator* ShaderGenerator = Ogre::RTShader::ShaderGenerator::getSingletonPtr();
  ShaderGenerator->createShaderBasedTechnique( MaterialName,
          Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
          Ogre::MaterialManager::DEFAULT_SCHEME_NAME,
          Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);
        //next line throws the exception............
        ShaderGenerator->validateMaterial(Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME, MaterialName); 
  }        
RTSS: The target shader language is HLSL version 4.0.

After googling for error X3025. I guess that the RTSS is generating older code then version HLSL_4.0.
Setting the D3DXSHADER_ENABLE_BACKWARDS_COMPATIBILITY could maybe solve the problem, but how to tell Ogre?
Is this a bug in RTSS?
Or am i complete wrong and setting setLightingEnabled(true) and setVertexColourTracking(Ogre::TVC_DIFFUSE) is a bad idea for some reasons?
paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: RTSS/DX11: error X3025: out parameters require l-value arguments

Post by paroj »

this is a bug or rather "missing feature" in RTSS.

Backwards compatibility is set here:
https://github.com/OGRECave/ogre/blob/5 ... .cpp#L1514

but this should be already enabled by default.

Probably we have to port this code to HLSL as well:
https://github.com/OGRECave/ogre/blob/m ... r.cpp#L212

it automatically creates a local variable if the shader tries to write to a "const" global.

If you write the shader to disk (as you probably do), you can just change the source code manually and see whether introducing a writable local variable solves the issue. Also see:
https://ogrecave.github.io/ogre/api/1.1 ... #debugging
ManVsOgre
Gnoblar
Posts: 7
Joined: Thu Jan 18, 2018 3:58 pm

Re: RTSS/DX11: error X3025: out parameters require l-value arguments

Post by ManVsOgre »

You make my Day :D
Probably we have to port this code to HLSL as well:
https://github.com/OGRECave/ogre/blob/m ... r.cpp#L212
That would be nice :)
If you write the shader to disk (as you probably do), you can just change the source code manually and see whether introducing a writable local variable solves the issue. Also see:
https://ogrecave.github.io/ogre/api/1.1 ... #debugging
I will try that. Many Thanks paroj!!!
ManVsOgre
Gnoblar
Posts: 7
Joined: Thu Jan 18, 2018 3:58 pm

Re: RTSS/DX11: error X3025: out parameters require l-value arguments

Post by ManVsOgre »

... and see whether introducing a writable local variable solves the issue
Unfortunately i 'm not able to solve this task :x

if i use the (non local variable) oColor_0, all is fine.

Code: Select all

FFP_Modulate(iColor_0, light_diffuse1, oColor_0); // writing to oColor_o
FFP_Light_Directional_Diffuse(inverse_transpose_worldview_matrix, iNormal_0,
light_position_view_space0.xyz, oColor_0.xyz, oColor_0.xyz, oColor_0.xyz); // read from oColor_o.xyz
But if i introduce a local variable local_Var1. The FFP_Modulate() is not writing to it.

Code: Select all

float4 local_Var1 = float4(light_diffuse1); // 1) create a local variable
FFP_Modulate(iColor_0, light_diffuse1, local_Var1);// 2) should write to local variable! But it doesn't!!
FFP_Light_Directional_Diffuse(inverse_transpose_worldview_matrix, iNormal_0, 
light_position_view_space0.xyz, local_Var1.xyz, oColor_0.xyz, oColor_0.xyz);// read local variable


What am i missing? How to make writable local variables in HLSL?
I also tried to use a static global, but without success.

I spend already hours with googling.... now i'm stuck.
Any hints or links would be very helpful!
paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: RTSS/DX11: error X3025: out parameters require l-value arguments

Post by paroj »

what do you mean by "is not writing"? The shader code seems reasonable to me.
ManVsOgre
Gnoblar
Posts: 7
Joined: Thu Jan 18, 2018 3:58 pm

Re: RTSS/DX11: error X3025: out parameters require l-value arguments

Post by ManVsOgre »

Thanks, you are right! The shader should be fine.

Code: Select all

float3 local_Var1 = float3(0.0, 0.0, 0.0);
FFP_Modulate(iColor_0.xyz, light_diffuse1.xyz, local_Var1);
FFP_Light_Directional_Diffuse(inverse_transpose_worldview_matrix, iNormal_0,
 light_position_view_space0.xyz, local_Var1, oColor_0.xyz, oColor_0.xyz);


I thougth my shader was wrong, because i get diffrent behavior in Ogre 1.10 DX11 compared to DX9 and OpenGL.
DX9 and OpenGL
Image
DX11
Image

With Ogre 1.9 i had the correct behavior. So there should be a porting error in my code to Ogre 1.10.
I will check that and write again.
paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: RTSS/DX11: error X3025: out parameters require l-value arguments

Post by paroj »

looks like it is rather a blending issue.

also note that while being vastly improved the D3D11 RS is still not as well tested as D3D9 and the GL Systems, so you should be prepared to fix some bugs there. (and preferably create a pull request for them)
ManVsOgre
Gnoblar
Posts: 7
Joined: Thu Jan 18, 2018 3:58 pm

Re: RTSS/DX11: error X3025: out parameters require l-value arguments

Post by ManVsOgre »

With Ogre 1.9 i had the correct behavior.
Sorry, i was wrong :oops:
I found out, that a later bugfix in my 1.9 code was not ported to my 1.10 code, therefore the diffrent behavior.

The topic is solved. Thanks again!
Post Reply