[DirectX 10] Texture Objects and Samplers and Bears! Oh my!

Started by
3 comments, last by L. Spiro 11 years, 10 months ago
I just need a little clarification on the relationships between texture objects, samplers, and texture units.

Speaking in Direct3D 9 terms for a moment, let us say I have 3 textures active in slots 0, 1, and 7.
In Direct3D 10, my original idea was that assigning Texture2D to registers t0, t1, and t7 would read each of these textures.
And then I could have 1 sampler shared between all of the Texture2D objects (if they are all to be sampled the same way).
I am fairly sure this is correct, but what then is the new purpose of the s# set of registers? In Direct3D 9 they would be used to match a sampler to a texture unit. Now they have basically no meaning aside from internal storage?


And what filters are used if a generic sampler is used (Sample2D for example)?
In Direct3D 9 there are D3DSAMP_MINFILTER etc. The Direct3D 10 equivalent (if there is one) will be used if no sampler_state parameters are applied? Or is it all up to the shader entirely?


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

Advertisement
Just as you would use VS/PS/GSSetShaderResources() to assign texture views to the specified registers, you use VSSetSamplers() to set samplers to sampler slots. There is no matching between texture and sampler registers, you pass a sampler as an argument to a Sample()-call, so it's possible to 'reuse' the same sampler on different texture objects.

You can use the Gather/Load family of texture methods to fetch texels without sampling/filtering.
In my engine during the start-up routine I create all samplers the game will need and assign each one of them to a sampler register, this way every shader will have access to every sampler needed and I only have to to xSSetSamplers() once during the entire game lifetime.

I'm not sure if there is a generic sampler but if there is it will probably use Min_Mag_Mip_Point filter because thats the default value of the D3D10_SAMPLER_DESC structure.
From the SDK:
Any sampler may be set to NULL; this invokes the default state, which is defined to be the following.

//Default sampler state:
D3D10_SAMPLER_DESC SamplerDesc;
SamplerDesc.Filter = D3D10_FILTER_MIN_MAG_MIP_LINEAR;
SamplerDesc.AddressU = D3D10_TEXTURE_ADDRESS_CLAMP;
SamplerDesc.AddressV = D3D10_TEXTURE_ADDRESS_CLAMP;
SamplerDesc.AddressW = D3D10_TEXTURE_ADDRESS_CLAMP;
SamplerDesc.MipLODBias = 0;
SamplerDesc.MaxAnisotropy = 1;
SamplerDesc.ComparisonFunc = D3D10_COMPARISON_NEVER;
SamplerDesc.BorderColor[0] = 1.0f;
SamplerDesc.BorderColor[1] = 1.0f;
SamplerDesc.BorderColor[2] = 1.0f;
SamplerDesc.BorderColor[3] = 1.0f;
SamplerDesc.MinLOD = -FLT_MAX;
SamplerDesc.MaxLOD = FLT_MAX;[/quote]

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

Thank you; it is clear now. I have to think about what kind of architectural changes I will need to make to my engine to handle this method of setting filters/sampler states.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

This topic is closed to new replies.

Advertisement