tags:

views:

380

answers:

2

That's about DirectX 9.

In typical case of rendering with vertex shader, there's one or more stream sources set in device, and format of the source data is defined using vertex declaration.

Now, if a vertex shader used need some attribute (for example, one with D3DDECLUSAGE_NORMAL and UsageIndex 1 or 2), but vertex declaration that's provided doesn't have that attribute included (ie. data provided in stream sources doesn't include that attribute), and DrawPrimitive is called, where does DirectX get value for that attribute?

A: 

The DirectX 9 specification defines "default" values for undeclared attributes, usually (0,0,0,1). Either the device driver or GPU creates them.

gatorfax
Where can I find this specification? It doesn't seem to be available anywhere Google can find it - and I need specific values for all semantics. I'm aware that in case of missing attribute components they're filled with 0s, and 1 for w, but I could find no doucmentation for values of whole missing attributes. Additionally Wine code seems to indicate they're taken from the beginning of vertex buffer - if Wine simulates that part correctly.
Yaten512
It's probably not in the SDK (or public). It's not meant to be a feature that applications are supposed to use but to define the behavior of GPUs under these conditions. This is tested by the WLK.I've seen it in the DX speclets and the WDK. It's part of the specification for IHVs to design their HW and drivers, not application developers.That's just how Wine is implemented. Every IHV will have their own unique solution.
gatorfax
The application I'm developing needs to simulate DirectX behaviour in this regard, that's why I need this information. Oh well, I guess I'll write test programs to get it.
Yaten512
A: 

"If the data in the vertex stream contains fewer components than the corresponding shader data type, the missing components will be initialized to 0 (except for w, which is initialized to 1)."

Taken from "Windows DirectX Graphics Documentation (August 2009)"

Contents > HLSL > Programming Guide > Writing HLSL Shaders in Direct3D 9 > Varying Shader Inputs and Semantics

Tom Johnstone