Page 1 of 1

HLMS Shader Error on Specific Texture Resolutions

Posted: Tue Jun 25, 2019 12:20 pm
by Smooth
Hi,

I have an application that uses HLMS and when I try to run it in debug mode I'm getting the following error:

Code: Select all

System.Exception: 'Unmanaged exception:
OGRE EXCEPTION(3:RenderingAPIException): D3D11 device cannot Clear State
Error Description:ID3D11DeviceContext::DrawIndexedInstanced: The Shader Resource View dimension declared in the shader code (TEXTURE2D) is not an array type but the view bound to slot 4 of the Pixel Shader unit has ArraySize 10.  This mismatch is invalid if the shader actually uses the view (e.g. it is not skipped due to shader code branching).
I'm not an expert on HLSL or any other shader languages, so it is a bit hard to get any meaning out of the error message. Can someone please explain what this error means?

I have done some tests and it seems to be related to the resolution of my texture on the material. I'm getting this error when the texture is exactly 1024px x 1024px, and it seems to work fine on other resolutions.

Has anyone else experienced this?

This is my material json settings file :

Code: Select all

{
	"samplers" :
	{
		"sampler0" :
		{
			"min" : "linear",
			"mag" : "linear",
			"mip" : "linear",
			"u" : "wrap",
			"v" : "wrap",
			"w" : "wrap",
			"miplodbias" : 0.0,
			"max_anisotropic" : 1.0,
			"compare_function" : "disabled",
			"min_lod" : -1e+07,
			"max_lod" : 1e+07
		}
	},
	"macroblocks" :
	{
		"macroblock0" :
		{
			"scissor_test" : false,
			"depth_check" : true,
			"depth_write" : true,
			"depth_function" : "less_equal",
			"depth_bias_constant" : 0,
			"depth_bias_slope_scale" : 0,
			"cull_mode" : "clockwise",
			"polygon_mode" : "solid"
		}
	},
	"blendblocks" :
	{
		"blendblock0" :
		{
			"alpha_to_coverage" : false,
			"blendmask" : "rgba",
			"separate_blend" : false,
			"src_blend_factor" : "one",
			"dst_blend_factor" : "one_minus_src_alpha",
			"blend_operation" : "add"
		}
	},
	"pbs" : 
	{
		"testMaterial" :
		{
			"macroblock" : "macroblock0",
			"blendblock" : "blendblock0",
			"shadow_const_bias" : 0.01,
			"workflow" :"metallic",
			"diffuse" : 
			{
				"value" : [0.886275, 0.564706, 0.0],
				"uv" : 0,
				"texture" : "texture.jpg", 
				"sampler" : "sampler0"
			},
			"roughness" : 
			{
				"value" : 0.6
			},
			"metalness" : 
			{
				"value" : 0.1
			}
		}
	}
}

Re: HLMS Shader Error on Specific Texture Resolutions

Posted: Tue Jun 25, 2019 3:59 pm
by dark_sylinc
Hi!

Is this Ogre 2.1 or 2.2?

Are you creating texture.jpg via C++ code or is it loaded from file? Are you creating any texture from C++ code?

The error message is complaining that you/we are passing a TEX_TYPE_2D (TextureTypes::Type2D in 2.2) when the shader expects TEX_TYPE_2D_ARRAY (TextureTypes::Type2DArray).

If you're creating the texture manually, you need to create it as TEX_TYPE_2D_ARRAY even it just contains 1 slice. The same applies if you're using an Ogre texture created by a third party library (e.g. from a GUI library?)

If you're loading the texture from file, it is a weird error to have, specially if it depends on resolution as you say.

Re: HLMS Shader Error on Specific Texture Resolutions

Posted: Tue Jun 25, 2019 3:59 pm
by dark_sylinc
Hi!

Is this Ogre 2.1 or 2.2?

Are you creating texture.jpg via C++ code or is it loaded from file? Are you creating any texture from C++ code?

The error message is complaining that you/we are passing a TEX_TYPE_2D (TextureTypes::Type2D in 2.2) when the shader expects TEX_TYPE_2D_ARRAY (TextureTypes::Type2DArray).

If you're creating the texture manually, you need to create it as TEX_TYPE_2D_ARRAY even it just contains 1 slice. The same applies if you're using an Ogre texture created by a third party library (e.g. from a GUI library?)

If you're loading the texture from file, it is a weird error to have, specially if it depends on resolution as you say.