I'm testing Ogre 2.2 and encountered a bug in Ogre.
As soon as a datablock gets cloned, in renderOneFrame later, the application does crash in:
ID3D11PixelShader* D3D11HLSLProgram::getPixelShader(void) const
{
assert(mType == GPT_FRAGMENT_PROGRAM);
assert(mPixelShader);
return mPixelShader;
}
Because the mPixelShader is 0. It does not matter which datablock is cloned.
Log:
Code: Select all
OGRE EXCEPTION(-2147467259:RenderingAPIException): Cannot compile D3D11 high-level shader 100000004PixelShader_ps Errors:
H:\GameEngineDevelopment2_2\bin\Debug\100000004PixelShader_ps.hlsl(715,35-62): error X4000: variable 'pixelData' used without having been completely initialized
in D3D11HLSLProgram::compileMicrocode at h:\gameenginedevelopment2_2\external\ogre2.2sdk\rendersystems\direct3d11\src\ogred3d11hlslprogram.cpp (line 558)
Code: Select all
#if 0
*** first_valid_detail_map_nm 0
*** hlms_dual_paraboloid_mapping 0
*** envprobe_map_sampler 1
*** hlms_lights_spotparams 0
*** envMapRegSampler 1
*** emissive_map_sampler 1
*** hlms_disable_stage 0
*** hlms_lights_area_approx 0
*** specular_map_sampler 1
*** texcoord 0
*** fast_shader_build_hack 1
*** glsl 635204550
*** hlms_high_quality 0
*** hlms_num_shadow_map_lights 0
*** hlms_lights_directional 0
*** hlms_shadowcaster 1
*** samplerStateStart 1
*** alpha_test 0
*** roughness_map_sampler 1
*** glsles 1070293233
*** hw_gamma_write 1
*** detail_map_nm2_sampler 1
*** hlms_shadowcaster_directional 1
*** hlms_pssm_splits 0
*** hlms_lights_spot 0
*** detail_map1_sampler 1
*** detail_map_nm3_sampler 1
*** hlms_alphablend 1
*** hlms_num_shadow_map_textures 0
*** hlms_shadow_uses_depth_texture 1
*** detail_map3_sampler 1
*** materials_per_buffer 2
*** hw_gamma_read 1
*** hlms_skeleton 0
*** hlms_pssm_splits_minus_one -1
*** forward3d 0
*** partial_pso_clip_distances 0
*** syntax -334286542
*** NeedsMoreThan1BonePerVertex -1
*** hlms_lights_point 0
*** diffuse_map_sampler 1
*** metal -1698855755
*** detail_map_nm1_sampler 1
*** s_lights_directional_non_caster 0
*** uv_diffuse 0
*** detail_weight_map_sampler 1
*** hlms_lights_attenuation 0
*** detail_map_nm0_sampler 1
*** hlms_render_depth_only 1
*** normal_map_tex_sampler 1
*** detail_map2_sampler 1
*** full_pso_clip_distances 0
*** detail_map0_sampler 1
*** use_planar_reflections 0
*** hlsl -334286542
DONE DUMPING PROPERTIES
DONE DUMPING PIECES
#endif
//#include "SyntaxHighlightingMisc.h"
#define ushort uint
#define ogre_float4x3 float4x3
//Short used for read operations. It's an int in GLSL & HLSL. An ushort in Metal
#define rshort2 int2
//Short used for write operations. It's an int in GLSL. An ushort in HLSL & Metal
#define wshort2 uint2
#define toFloat3x3( x ) ((float3x3)(x))
#define buildFloat3x3( row0, row1, row2 ) transpose( float3x3( row0, row1, row2 ) )
#define min3( a, b, c ) min( a, min( b, c ) )
#define max3( a, b, c ) max( a, max( b, c ) )
#define INLINE
#define NO_INTERPOLATION_PREFIX nointerpolation
#define NO_INTERPOLATION_SUFFIX
#define finalDrawId input.drawId
#define PARAMS_ARG_DECL
#define PARAMS_ARG
#define floatBitsToUint(x) asuint(x)
#define uintBitsToFloat(x) asfloat(x)
#define floatBitsToInt(x) asint(x)
#define fract frac
#define lessThan( a, b ) (a < b)
#define inVs_vertexId input.vertexId
#define inVs_vertex input.vertex
#define inVs_blendWeights input.blendWeights
#define inVs_blendIndices input.blendIndices
#define inVs_qtangent input.qtangent
#define inVs_drawId input.drawId
#define outVs_Position outVs.gl_Position
#define outVs_clipDistance0 outVs.gl_ClipDistance0
#define gl_SampleMaskIn0 gl_SampleMask
#define interpolateAtSample( interp, subsample ) EvaluateAttributeAtSample( interp, subsample )
#define findLSB firstbitlow
#define outPs_colour0 outPs.colour0
#define OGRE_Sample( tex, sampler, uv ) tex.Sample( sampler, uv )
#define OGRE_SampleLevel( tex, sampler, uv, lod ) tex.SampleLevel( sampler, uv, lod )
#define OGRE_SampleArray2D( tex, sampler, uv, arrayIdx ) tex.Sample( sampler, float3( uv, arrayIdx ) )
#define OGRE_SampleArray2DLevel( tex, sampler, uv, arrayIdx, lod ) tex.SampleLevel( sampler, float3( uv, arrayIdx ), lod )
#define OGRE_SampleArrayCubeLevel( tex, sampler, uv, arrayIdx, lod ) tex.SampleLevel( sampler, float4( uv, arrayIdx ), lod )
#define OGRE_SampleGrad( tex, sampler, uv, ddx, ddy ) tex.SampleGrad( sampler, uv, ddx, ddy )
#define OGRE_SampleArray2DGrad( tex, sampler, uv, arrayIdx, ddx, ddy ) tex.SampleGrad( sampler, float3( uv, arrayIdx ), ddx, ddy )
#define OGRE_ddx( val ) ddx( val )
#define OGRE_ddy( val ) ddy( val )
#define OGRE_Load2D( tex, iuv, lod ) tex.Load( int3( iuv, lod ) )
#define OGRE_Load2DMS( tex, iuv, subsample ) tex.Load( iuv, subsample )
#define bufferFetch( buffer, idx ) buffer.Load( idx )
#define bufferFetch1( buffer, idx ) buffer.Load( idx ).x
#define CONST_BUFFER( bufferName, bindingPoint ) cbuffer bufferName : register(b##bindingPoint)
#define CONST_BUFFER_STRUCT_BEGIN( structName, bindingPoint ) cbuffer structName : register(b##bindingPoint) { struct _##structName
#define CONST_BUFFER_STRUCT_END( variableName ) variableName; }
#define FLAT_INTERPOLANT( decl, bindingPoint ) nointerpolation decl : TEXCOORD##bindingPoint
#define INTERPOLANT( decl, bindingPoint ) decl : TEXCOORD##bindingPoint
#define UV_DIFFUSE(x) (x)
#define UV_NORMAL(x) (x)
#define UV_SPECULAR(x) (x)
#define UV_ROUGHNESS(x) (x)
#define UV_DETAIL_WEIGHT(x) (x)
#define UV_DETAIL0(x) (x)
#define UV_DETAIL1(x) (x)
#define UV_DETAIL2(x) (x)
#define UV_DETAIL3(x) (x)
#define UV_DETAIL_NM0(x) (x)
#define UV_DETAIL_NM1(x) (x)
#define UV_DETAIL_NM2(x) (x)
#define UV_DETAIL_NM3(x) (x)
#define UV_EMISSIVE(x) (x)
#define float_fresnel float
#define make_float_fresnel( x ) x
#define OGRE_DEPTH_CMP_GE( a, b ) (a) <= (b)
#define OGRE_DEPTH_DEFAULT_CLEAR 0.0
struct PixelData
{
float4 diffuse; //We only use the .w component, Alpha
};
#define SampleDetailWeightMap( tex, sampler, uv, arrayIdx ) OGRE_SampleArray2D( tex, sampler, uv, arrayIdx )
// START UNIFORM DECLARATION
// END UNIFORM DECLARATION
struct PS_INPUT
{
};
///!hlms_shadowcaster
#define outDepth outPs.colour0
struct PS_OUTPUT
{
float colour0 : SV_Depth;
};
void main( PS_INPUT inPs )
{
}
Code: Select all
#if 0
*** first_valid_detail_map_nm 0
*** hlms_dual_paraboloid_mapping 0
*** hlms_lights_spotparams 0
*** hlms_lights_area_approx 0
*** fast_shader_build_hack 1
*** glsl 635204550
*** hlms_high_quality 0
*** hlms_num_shadow_map_lights 0
*** hlms_lights_directional 0
*** hlms_shadowcaster 1
*** samplerStateStart 1
*** alpha_test 0
*** glsles 1070293233
*** hw_gamma_write 1
*** hlms_shadowcaster_directional 1
*** hlms_pssm_splits 0
*** hlms_lights_spot 0
*** hlms_alphablend 1
*** hlms_num_shadow_map_textures 0
*** hlms_shadow_uses_depth_texture 1
*** materials_per_buffer 2
*** hw_gamma_read 1
*** hlms_skeleton 0
*** forward3d 0
*** syntax -334286542
*** hlms_lights_point 0
*** metal -1698855755
*** s_lights_directional_non_caster 0
*** uv_diffuse 0
*** hlms_lights_attenuation 0
*** hlms_render_depth_only 1
*** use_planar_reflections 0
*** hlsl -334286542
DONE DUMPING PROPERTIES
DONE DUMPING PIECES
#endif
//#include "SyntaxHighlightingMisc.h"
#define ushort uint
#define ogre_float4x3 float4x3
//Short used for read operations. It's an int in GLSL & HLSL. An ushort in Metal
#define rshort2 int2
//Short used for write operations. It's an int in GLSL. An ushort in HLSL & Metal
#define wshort2 uint2
#define toFloat3x3( x ) ((float3x3)(x))
#define buildFloat3x3( row0, row1, row2 ) transpose( float3x3( row0, row1, row2 ) )
#define min3( a, b, c ) min( a, min( b, c ) )
#define max3( a, b, c ) max( a, max( b, c ) )
#define INLINE
#define NO_INTERPOLATION_PREFIX nointerpolation
#define NO_INTERPOLATION_SUFFIX
#define finalDrawId input.drawId
#define PARAMS_ARG_DECL
#define PARAMS_ARG
#define floatBitsToUint(x) asuint(x)
#define uintBitsToFloat(x) asfloat(x)
#define floatBitsToInt(x) asint(x)
#define fract frac
#define lessThan( a, b ) (a < b)
#define inVs_vertexId input.vertexId
#define inVs_vertex input.vertex
#define inVs_blendWeights input.blendWeights
#define inVs_blendIndices input.blendIndices
#define inVs_qtangent input.qtangent
#define inVs_drawId input.drawId
#define outVs_Position outVs.gl_Position
#define outVs_clipDistance0 outVs.gl_ClipDistance0
#define gl_SampleMaskIn0 gl_SampleMask
#define interpolateAtSample( interp, subsample ) EvaluateAttributeAtSample( interp, subsample )
#define findLSB firstbitlow
#define outPs_colour0 outPs.colour0
#define OGRE_Sample( tex, sampler, uv ) tex.Sample( sampler, uv )
#define OGRE_SampleLevel( tex, sampler, uv, lod ) tex.SampleLevel( sampler, uv, lod )
#define OGRE_SampleArray2D( tex, sampler, uv, arrayIdx ) tex.Sample( sampler, float3( uv, arrayIdx ) )
#define OGRE_SampleArray2DLevel( tex, sampler, uv, arrayIdx, lod ) tex.SampleLevel( sampler, float3( uv, arrayIdx ), lod )
#define OGRE_SampleArrayCubeLevel( tex, sampler, uv, arrayIdx, lod ) tex.SampleLevel( sampler, float4( uv, arrayIdx ), lod )
#define OGRE_SampleGrad( tex, sampler, uv, ddx, ddy ) tex.SampleGrad( sampler, uv, ddx, ddy )
#define OGRE_SampleArray2DGrad( tex, sampler, uv, arrayIdx, ddx, ddy ) tex.SampleGrad( sampler, float3( uv, arrayIdx ), ddx, ddy )
#define OGRE_ddx( val ) ddx( val )
#define OGRE_ddy( val ) ddy( val )
#define OGRE_Load2D( tex, iuv, lod ) tex.Load( int3( iuv, lod ) )
#define OGRE_Load2DMS( tex, iuv, subsample ) tex.Load( iuv, subsample )
#define bufferFetch( buffer, idx ) buffer.Load( idx )
#define bufferFetch1( buffer, idx ) buffer.Load( idx ).x
#define CONST_BUFFER( bufferName, bindingPoint ) cbuffer bufferName : register(b##bindingPoint)
#define CONST_BUFFER_STRUCT_BEGIN( structName, bindingPoint ) cbuffer structName : register(b##bindingPoint) { struct _##structName
#define CONST_BUFFER_STRUCT_END( variableName ) variableName; }
#define FLAT_INTERPOLANT( decl, bindingPoint ) nointerpolation decl : TEXCOORD##bindingPoint
#define INTERPOLANT( decl, bindingPoint ) decl : TEXCOORD##bindingPoint
#define worldViewMat worldView
float4x4 UNPACK_MAT4( Buffer<float4> matrixBuf, uint pixelIdx )
{
float4 row1 = matrixBuf.Load( int((pixelIdx) << 2u) );
float4 row2 = matrixBuf.Load( int(((pixelIdx) << 2u) + 1u) );
float4 row3 = matrixBuf.Load( int(((pixelIdx) << 2u) + 2u) );
float4 row4 = matrixBuf.Load( int(((pixelIdx) << 2u) + 3u) );
return transpose( float4x4( row1, row2, row3, row4 ) );
}
float4x3 UNPACK_MAT4x3( Buffer<float4> matrixBuf, uint pixelIdx )
{
float4 row1 = matrixBuf.Load( int((pixelIdx) << 2u) );
float4 row2 = matrixBuf.Load( int(((pixelIdx) << 2u) + 1u) );
float4 row3 = matrixBuf.Load( int(((pixelIdx) << 2u) + 2u) );
return transpose( float3x4( row1, row2, row3 ) );
}
// START UNIFORM DECLARATION
struct ShadowReceiverData
{
float4x4 texViewProj;
float2 shadowDepthRange;
float2 padding;
float4 invShadowMapSize;
};
struct Light
{
float3 position;
uint lightMask;
float4 diffuse; //.w contains numNonCasterDirectionalLights
float3 specular;
};
#define numNonCasterDirectionalLights lights[0].diffuse.w
#define areaLightDiffuseMipmapStart areaApproxLights[0].diffuse.w
#define areaLightNumMipmapsSpecFactor areaApproxLights[0].specular.w
#define numAreaApproxLights areaApproxLights[0].doubleSided.y
#define numAreaApproxLightsWithMask areaApproxLights[0].doubleSided.z
#define numAreaLtcLights areaLtcLights[0].points[0].w
struct AreaLight
{
float3 position;
uint lightMask;
float4 diffuse; //[0].w contains diffuse mipmap start
float4 specular; //[0].w contains mipmap scale
float4 attenuation; //.w contains texture array idx
//Custom 2D Shape:
// direction.xyz direction
// direction.w invHalfRectSize.x
// tangent.xyz tangent
// tangent.w invHalfRectSize.y
float4 direction;
float4 tangent;
float4 doubleSided; //.y contains numAreaApproxLights
//.z contains numAreaApproxLightsWithMask
};
struct AreaLtcLight
{
float3 position;
uint lightMask;
float4 diffuse; //.w contains attenuation range
float4 specular; //.w contains doubleSided
float4 points[4]; //.w contains numAreaLtcLights
};
//Uniforms that change per pass
CONST_BUFFER_STRUCT_BEGIN( PassBuffer, 0 )
{
//Vertex shader (common to both receiver and casters)
float4x4 viewProj;
//Vertex shader
float2 depthRange;
}
CONST_BUFFER_STRUCT_END( passBuf );
//Uniforms that change per Item/Entity
CONST_BUFFER( InstanceBuffer, 2 )
{
//.x =
//The lower 9 bits contain the material's start index.
//The higher 23 bits contain the world matrix start index.
//
//.y =
//shadowConstantBias. Send the bias directly to avoid an
//unnecessary indirection during the shadow mapping pass.
//Must be loaded with uintBitsToFloat
//
//.z =
//lightMask. Ogre must have been compiled with OGRE_NO_FINE_LIGHT_MASK_GRANULARITY
uint4 worldMaterialIdx[2];
};
// END UNIFORM DECLARATION
struct VS_INPUT
{
float4 vertex : POSITION;
uint drawId : DRAWID;
};
struct PS_INPUT
{
float4 gl_Position: SV_Position;
};
// START UNIFORM D3D DECLARATION
Buffer<float4> worldMatBuf : register(t0);
// END UNIFORM D3D DECLARATION
PS_INPUT main( VS_INPUT input )
{
PS_INPUT outVs;
ogre_float4x3 worldMat = UNPACK_MAT4x3( worldMatBuf, inVs_drawId );
float4 worldPos = float4( mul(inVs_vertex, worldMat).xyz, 1.0f );
//Lighting is in view space
outVs_Position = mul( worldPos, passBuf.viewProj );
float shadowConstantBias = uintBitsToFloat( worldMaterialIdx[inVs_drawId].y );
//We can't make the depth buffer linear without Z out in the fragment shader;
//however we can use a cheap approximation ("pseudo linear depth")
//see http://www.yosoygames.com.ar/wp/2014/01/linear-depth-buffer-my-ass/
outVs_Position.z = outVs_Position.z + shadowConstantBias * passBuf.depthRange.y * passBuf.depthRange.y;
/// hlms_uv_count will be 0 on shadow caster passes w/out alpha test
return outVs;
}
Best Regards
Lax