[Solved in 1.6] tex_coord_set and D3D debug runtime

What it says on the tin: a place to discuss proposed new features.
Post Reply
User avatar
cdleonard
Goblin
Posts: 266
Joined: Thu May 31, 2007 9:45 am

[Solved in 1.6] tex_coord_set and D3D debug runtime

Post by cdleonard »

The Direct3D debug runtime wants texture coordinate sets to match texture units numbers when using shaders. This is very silly since if you use shaders then texture coordinate sets have no effect anyway.

By default tex_coord_set in Ogre is set to 0 and this will make the debug runtime complain. This applies to all materials which use both multiple textures and shaders. Can't Ogre's Direct3D renderer ignore tex_coord_set from the material and just give Direct3D what it wants?

I'm not sure how useful the Direct3D debug runtime really is but this issue makes it unusable. The workaround is to go in all material scripts and count texture units.
Last edited by cdleonard on Tue Sep 30, 2008 2:24 pm, edited 1 time in total.
User avatar
Praetor
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3335
Joined: Tue Jun 21, 2005 8:26 pm
Location: Rochester, New York, US
x 3
Contact:

Post by Praetor »

I'm not sure what you mean by this. I don't use the Direct3D debug runtime (though i definitely should!) and so I haven't had the problem. Can you give an example of what gives the problem and then a theoretical example of what fixes it? What exactly does Direct3D expect?
User avatar
cdleonard
Goblin
Posts: 266
Joined: Thu May 31, 2007 9:45 am

Post by cdleonard »

To use the Direct3D debug runtime you need the DirectX SDK. There's something called the "DirectX control panel" in there with a switch to the debug runtime; which is supposed to do more validation. There's a checkbox in there to "Break on D3D error"; that will break into the debugger from inside the DrawIndexedPrimitive call.

A sample material is something like:

Code: Select all

material Sample
{
	technique
	{
		pass
		{
			vertex_program_ref SomeVP
			{
			}
			
			fragment_program_ref SomeFP
			{
			}

			texture_unit Texture0
			{
				texture Texture0.bmp
				tex_coord_set 0
			}

			texture_unit Texture1
			{
				texture Texture1.bmp
				tex_coord_set 1 // D3D needs this line.
			}
		}
	}
}
D3D needs tex_coord_set to be equal to the texture unit number; even though it has no effect.
User avatar
Praetor
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3335
Joined: Tue Jun 21, 2005 8:26 pm
Location: Rochester, New York, US
x 3
Contact:

Post by Praetor »

Interesting, because that is semantically not what you want. Even if it has no effect. If you happened to have multiple texture coords in your models then that indeed will have an effect, which is possibly not desired.
User avatar
cdleonard
Goblin
Posts: 266
Joined: Thu May 31, 2007 9:45 am

Post by cdleonard »

If you do have multiple texture coordinate sets you receive them in the vertex shader and can play with them in there (and mostly likely pass them on to the pixel shader). In the pixel shader you sample your own textures explicitly.

If you use BOTH vertex and pixel shaders then you control everything that flows between them. It that case tex_coord_set has no effect. Whatever you write to TEXCOORD* in the vertex shader you read from TEXCOORD* in the pixel shader (after interpolation).

Actually on very old (ps 1_*) cards there are some limitations on how you can sample your textures. I don't know the details; but there was a mandatory connection between TEXCOORD* inputs and s* texture samplers. Maybe that's what this validation is about?
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Post by sinbad »

Yes, it's because of the way D3D interprets the texture coord binding information, with shaders they have to be bound to the matching semantics. Yes, I believe it's a hangover from the Dx8 transition to shaders that it's bitchy about them.

Since the directives are dependent on your material set up I've left it to the material but I guess we could automate this...

[edit]done...
User avatar
cdleonard
Goblin
Posts: 266
Joined: Thu May 31, 2007 9:45 am

Post by cdleonard »

Thank you!
Post Reply