Sign in to follow this  
L. Spiro

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

Recommended Posts

L. Spiro    25622
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

Share this post


Link to post
Share on other sites
eppo    4877
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. Edited by eppo

Share this post


Link to post
Share on other sites
Aqua Costa    3691
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.

Share this post


Link to post
Share on other sites
mhagain    13430
From the SDK:
[quote]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]

Share this post


Link to post
Share on other sites
L. Spiro    25622
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this