Creating a new sampler state without a shader?

Started by
10 comments, last by _damN_ 14 years, 1 month ago
Hi! Im trying to create a new sampler state using D3D10,so i can add texture filtering but i dont want to do it within a shader. I dont think its working because i cant seem to see a difference at all? This is what it looks like...
Quote: ZeroMemory(&samplerDesc, sizeof(D3D10_SAMPLER_DESC)); samplerDesc.AddressU = D3D10_TEXTURE_ADDRESS_CLAMP; samplerDesc.AddressV = D3D10_TEXTURE_ADDRESS_CLAMP; samplerDesc.AddressW = D3D10_TEXTURE_ADDRESS_CLAMP; samplerDesc.ComparisonFunc = D3D10_COMPARISON_NEVER; samplerDesc.Filter = D3D10_FILTER_MIN_MAG_POINT_MIP_LINEAR; samplerDesc.MaxAnisotropy = 0.0f; samplerDesc.MaxLOD = FLT_MAX; samplerDesc.MinLOD = 0.0f; samplerDesc.MipLODBias =0.0; ID3D10SamplerState* samplerState; m_pD3DDevice->CreateSamplerState(&samplerDesc,&samplerState); m_pD3DDevice->PSSetSamplers(0,1,&samplerState);
I cant find any decent DX10 examples on the net and if i do find one they use a shader. Can anybody help? Thanks!
Advertisement
I find your question a bit confusing - Since DX10 only allows rendering to be done through shaders what would you do with a device with texture filtering applied?

Secondly the sampler creation below doesn't require a shader interface, only a functional device.

Could you try and specify what exactly you need to do.
I think he wants to specify the sampler state in C++ code as opposed to in a D3D10 Effects file.

When you declare the sampler in HLSL did you specify a register to put it in?
Apologies... Let me try and clear things up. Im pretty new to directX. I want to turn on texture filtering so i can render my cube using the filter D3D10_FILTER_MIN_MAG_POINT_MIP_LINEAR or D3D10_FILTER_ANISOTROPIC and play around with texture qualities.

Are you saying i will only be able to do this in a shader? There are so few tutorials on DX10 on the net its difficult to know how to do this properly. I have a book which shows you how to do this in a shader but i dont really wanto do it in a shader, i wanto do it it my code(source file) itself. There has to be a way, surely!

Does that make a bit more sense? How would i fill the descriptor and set it to active?

Thanks
I nice code example would be greatly apreciated!

Quote:
I think he wants to specify the sampler state in C++ code as opposed to in a D3D10 Effects file.

When you declare the sampler in HLSL did you specify a register to put it in?


What do you mean? Isnt that only when i use a shader? You are right, i want to do it in C++ code instead of in an effect file.
Well, the code sample you showed is correct, but you still need a pixel shader and you need to refer to the sampler state in it even if you set it in code.

If you're new to all of this, I would just stick to declaring states in a .fx file. The Effect Framework is there to make your life easier.
Your code for filling out the D3D10_SAMPLER_DESC looks okay. However you want to create sampler states at initialization time, not at runtime. At runtime you only want to set states. Make sure you set the sampler state after applying an effect pass, otherwise the effect pass will override your state. Also, make sure that you're setting the sampler state to the correct sampler index. You can manually bind a sampler to an index in your HLSL like this:
SamplerState LinearSampler : register(s0);
You mean like so...

SamplerState gTriLinearSam: register(s0)
{
Filter = MIN_MAG_MIP_LINEAR;
};

???
Quote:Original post by _damN_
You mean like so...

SamplerState gTriLinearSam: register(s0)
{
Filter = MIN_MAG_MIP_LINEAR;
};

???


That is effects code when you include the initializer data. The pure HLSL bit is just

SamplerState gTriLinearSam: register(s0);


You don't need anything else in the HLSL code. The creation and binding will all happen in the runtime code by you.
There we go! It works! Thanks dude!

This topic is closed to new replies.

Advertisement