2012-09-15 13:43:31 +00:00
|
|
|
#region Using Statements
|
|
|
|
using System;
|
2011-12-14 11:49:04 +00:00
|
|
|
using ANX.Framework.Graphics;
|
|
|
|
using ANX.Framework.NonXNA;
|
2012-09-15 13:43:31 +00:00
|
|
|
|
|
|
|
#endregion
|
2011-12-14 11:49:04 +00:00
|
|
|
|
2012-08-09 09:45:04 +00:00
|
|
|
// This file is part of the ANX.Framework created by the
|
|
|
|
// "ANX.Framework developer group" and released under the Ms-PL license.
|
|
|
|
// For details see: http://anxframework.codeplex.com/license
|
2011-12-14 11:49:04 +00:00
|
|
|
|
2012-09-15 13:43:31 +00:00
|
|
|
using Dx11 = SharpDX.Direct3D11;
|
|
|
|
|
2011-12-14 11:49:04 +00:00
|
|
|
namespace ANX.RenderSystem.Windows.DX11
|
|
|
|
{
|
2012-09-07 09:48:45 +00:00
|
|
|
public class SamplerState_DX11 : BaseStateObject<Dx11.SamplerState>, INativeSamplerState
|
2011-12-14 11:49:04 +00:00
|
|
|
{
|
2012-09-07 09:48:45 +00:00
|
|
|
private Dx11.SamplerStateDescription description;
|
|
|
|
|
|
|
|
#region Public
|
|
|
|
public TextureAddressMode AddressU
|
|
|
|
{
|
|
|
|
set
|
|
|
|
{
|
|
|
|
Dx11.TextureAddressMode mode = FormatConverter.Translate(value);
|
|
|
|
SetValueIfDifferentAndMarkDirty(ref description.AddressU, ref mode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public TextureAddressMode AddressV
|
|
|
|
{
|
|
|
|
set
|
|
|
|
{
|
|
|
|
Dx11.TextureAddressMode mode = FormatConverter.Translate(value);
|
|
|
|
SetValueIfDifferentAndMarkDirty(ref description.AddressV, ref mode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public TextureAddressMode AddressW
|
|
|
|
{
|
|
|
|
set
|
|
|
|
{
|
|
|
|
Dx11.TextureAddressMode mode = FormatConverter.Translate(value);
|
|
|
|
SetValueIfDifferentAndMarkDirty(ref description.AddressW, ref mode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public TextureFilter Filter
|
|
|
|
{
|
|
|
|
set
|
|
|
|
{
|
|
|
|
Dx11.Filter filter = FormatConverter.Translate(value);
|
|
|
|
SetValueIfDifferentAndMarkDirty(ref description.Filter, ref filter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public int MaxAnisotropy
|
|
|
|
{
|
|
|
|
set
|
|
|
|
{
|
|
|
|
SetValueIfDifferentAndMarkDirty(ref description.MaximumAnisotropy, ref value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public int MaxMipLevel
|
|
|
|
{
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (description.MaximumLod != value)
|
|
|
|
{
|
|
|
|
description.MaximumLod = value;
|
|
|
|
isDirty = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public float MipMapLevelOfDetailBias
|
|
|
|
{
|
|
|
|
set
|
|
|
|
{
|
|
|
|
SetValueIfDifferentAndMarkDirty(ref description.MipLodBias, ref value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Apply
|
|
|
|
public void Apply(GraphicsDevice graphicsDevice, int index)
|
2011-12-14 11:49:04 +00:00
|
|
|
{
|
2012-09-15 13:43:31 +00:00
|
|
|
Dx11.DeviceContext context = (graphicsDevice.NativeDevice as GraphicsDeviceDX).NativeDevice;
|
2011-12-14 11:49:04 +00:00
|
|
|
|
|
|
|
UpdateNativeSamplerState(context.Device);
|
2012-09-07 09:48:45 +00:00
|
|
|
IsBound = true;
|
2011-12-14 11:49:04 +00:00
|
|
|
|
2012-09-07 09:48:45 +00:00
|
|
|
context.PixelShader.SetSampler(index, nativeState);
|
|
|
|
}
|
|
|
|
#endregion
|
2011-12-14 11:49:04 +00:00
|
|
|
|
2012-09-07 09:48:45 +00:00
|
|
|
#region UpdateNativeSamplerState
|
|
|
|
private void UpdateNativeSamplerState(Dx11.Device device)
|
2011-12-14 11:49:04 +00:00
|
|
|
{
|
2012-09-07 09:48:45 +00:00
|
|
|
if (isDirty || nativeState == null)
|
2011-12-14 11:49:04 +00:00
|
|
|
{
|
2012-09-07 09:48:45 +00:00
|
|
|
Dispose();
|
|
|
|
nativeState = new Dx11.SamplerState(device, ref description);
|
|
|
|
isDirty = false;
|
2011-12-14 11:49:04 +00:00
|
|
|
}
|
|
|
|
}
|
2012-09-07 09:48:45 +00:00
|
|
|
#endregion
|
2011-12-14 11:49:04 +00:00
|
|
|
|
2012-09-07 09:48:45 +00:00
|
|
|
protected override Dx11.SamplerState CreateNativeState(GraphicsDevice graphics)
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
2011-12-14 11:49:04 +00:00
|
|
|
|
2012-09-07 09:48:45 +00:00
|
|
|
protected override void ApplyNativeState(GraphicsDevice graphics)
|
|
|
|
{
|
|
|
|
}
|
2011-12-14 11:49:04 +00:00
|
|
|
}
|
|
|
|
}
|