Skip to content

Instantly share code, notes, and snippets.

@aras-p
Created February 13, 2017 12:13
Show Gist options
  • Save aras-p/a5d727524cf60884397bcc71630fe058 to your computer and use it in GitHub Desktop.
Save aras-p/a5d727524cf60884397bcc71630fe058 to your computer and use it in GitHub Desktop.
Default sampler states in HLSL :(
// HLSL does allow initializing sampler states with a syntax
// like this. However the state settings themselves are nowhere
// to be found in the compiled shader bytecode (as of d3dcompiler_47.dll
// 10.0.14393 from Win10 SDK), and can't be accessed via ID3D11ShaderReflection
// either.
//
// Looks like the compiler only emits the sampler default values if compiling
// the deprecated "effect file" target.
//
// SAD!
SamplerState smp { AddressU = Clamp; AddressV = Wrap; };
Texture2D tx;
float4 frag (float2 uv : TEXCOORD0) : SV_Target
{
return tx.Sample(smp, uv);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment