// Copyright (c) 2010-2014 SharpDX - Alexandre Mutel // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. using System; using SharpDX.Mathematics.Interop; namespace SharpDX.Direct2D1 { public partial class EffectContext { /// /// Gets the DPI. /// public RawVector2 Dpi { get { RawVector2 dpi; GetDpi(out dpi.X, out dpi.Y); return dpi; } /// HRESULT ID2D1EffectContext::GetMaximumSupportedFeatureLevel([In, Buffer] const D3D_FEATURE_LEVEL* featureLevels,[In] unsigned int featureLevelsCount,[Out] D3D_FEATURE_LEVEL* maximumSupportedFeatureLevel) } /// /// Gets the maximum feature level supported by this instance. /// /// An array of feature levels /// The maximum feature level selected from the array public SharpDX.Direct3D.FeatureLevel GetMaximumSupportedFeatureLevel(SharpDX.Direct3D.FeatureLevel[] featureLevels) { return GetMaximumSupportedFeatureLevel(featureLevels, featureLevels.Length); } /// /// Loads a pixel shader. /// /// An unique identifier associated with the shader bytecode. /// The bytecode of the shader. /// HRESULT ID2D1EffectContext::LoadPixelShader([In] const GUID& shaderId,[In, Buffer] const unsigned char* shaderBuffer,[In] unsigned int shaderBufferCount) public void LoadPixelShader(System.Guid shaderId, byte[] shaderBytecode) { LoadPixelShader(shaderId, shaderBytecode, shaderBytecode.Length); } /// /// Loads a vertex shader. /// /// An unique identifier associated with the shader bytecode. /// The bytecode of the shader. /// HRESULT ID2D1EffectContext::LoadVertexShader([In] const GUID& resourceId,[In, Buffer] const unsigned char* shaderBuffer,[In] unsigned int shaderBufferCount) public void LoadVertexShader(System.Guid shaderId, byte[] shaderBytecode) { LoadVertexShader(shaderId, shaderBytecode, shaderBytecode.Length); } /// /// Loads a compute shader. /// /// An unique identifier associated with the shader bytecode. /// The bytecode of the shader. /// HRESULT ID2D1EffectContext::LoadComputeShader([In] const GUID& resourceId,[In, Buffer] const unsigned char* shaderBuffer,[In] unsigned int shaderBufferCount) public void LoadComputeShader(System.Guid shaderId, byte[] shaderBytecode) { LoadComputeShader(shaderId, shaderBytecode, shaderBytecode.Length); } /// /// Check if this device is supporting a feature. /// /// The feature to check. /// /// Returns true if this device supports this feature, otherwise false. /// public bool CheckFeatureSupport(Feature feature) { unsafe { switch (feature) { case Feature.Doubles: { FeatureDataDoubles support; if (CheckFeatureSupport(Feature.Doubles, new IntPtr(&support), Utilities.SizeOf()).Failure) return false; return support.DoublePrecisionFloatShaderOps; } case Feature.D3D10XHardwareOptions: { FeatureDataD3D10XHardwareOptions support; if (CheckFeatureSupport(Feature.D3D10XHardwareOptions, new IntPtr(&support), Utilities.SizeOf()).Failure) return false; return support.ComputeShadersPlusRawAndStructuredBuffersViaShader4X; } default: throw new SharpDXException("Unsupported Feature. Use specialized CheckXXX methods"); } } } } }