[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 » Mon Sep 29, 2008 3:56 pm

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.
0 x

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
Contact:

Post by Praetor » Mon Sep 29, 2008 4:02 pm

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?
0 x

User avatar
cdleonard
Goblin
Posts: 266
Joined: Thu May 31, 2007 9:45 am

Post by cdleonard » Mon Sep 29, 2008 4:12 pm

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.
0 x

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
Contact:

Post by Praetor » Mon Sep 29, 2008 4:22 pm

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.
0 x

User avatar
cdleonard
Goblin
Posts: 266
Joined: Thu May 31, 2007 9:45 am

Post by cdleonard » Mon Sep 29, 2008 4:47 pm

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?
0 x

User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19265
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 2
Contact:

Post by sinbad » Tue Sep 30, 2008 12:21 pm

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...
0 x

User avatar
cdleonard
Goblin
Posts: 266
Joined: Thu May 31, 2007 9:45 am

Post by cdleonard » Tue Sep 30, 2008 2:22 pm

Thank you!
0 x

Post Reply