[slimdx] r2188 committed - Started adding Toolkit utility library.

8 views
Skip to first unread message

sli...@googlecode.com

unread,
Mar 18, 2012, 12:29:36 AM3/18/12
to slimdx...@googlegroups.com
Revision: 2188
Author: mike.popoloski
Date: Sat Mar 17 21:28:36 2012
Log: Started adding Toolkit utility library.
http://code.google.com/p/slimdx/source/detail?r=2188

Added:
/branches/lite/SlimDX.Toolkit
/branches/lite/SlimDX.Toolkit/Properties
/branches/lite/SlimDX.Toolkit/Properties/AssemblyInfo.cs
/branches/lite/SlimDX.Toolkit/SlimDX.Toolkit.csproj
/branches/lite/SlimDX.Toolkit/Sprites
/branches/lite/SlimDX.Toolkit/Sprites/SpriteBatch.cs
/branches/lite/SlimDX.Toolkit/Sprites/SpriteContextResources.cs
/branches/lite/SlimDX.Toolkit/Sprites/SpriteDeviceResources.cs
/branches/lite/SlimDX.Toolkit/Sprites/SpriteShaders.cs
/branches/lite/SlimDX.Toolkit/Utilities
/branches/lite/SlimDX.Toolkit/Utilities/SharedResourcePool.cs
/branches/lite/SlimDX.Toolkit/VertexTypes
Modified:
/branches/lite/SlimMath/Color4.cs
/branches/lite/SlimMath/Rational.cs
/branches/lite/SlimMath/SlimMath.csproj
/branches/lite/build/SlimDX.sln
/branches/lite/build/SlimDX.vcxproj
/branches/lite/source/Utilities.cpp
/branches/lite/source/direct3d11/Device11.cpp
/branches/lite/source/direct3d11/Device11.h

=======================================
--- /dev/null
+++ /branches/lite/SlimDX.Toolkit/Properties/AssemblyInfo.cs Sat Mar 17
21:28:36 2012
@@ -0,0 +1,38 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Resources;
+
+// General Information about an assembly is controlled through the
following
+// set of attributes. Change these attribute values to modify the
information
+// associated with an assembly.
+[assembly: AssemblyTitle("SlimDX.Toolkit")]
+[assembly: AssemblyDescription("Utility library for use with SlimDX.")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("SlimDX Group")]
+[assembly: AssemblyProduct("SlimDX.Toolkit")]
+[assembly: AssemblyCopyright("Copyright © 2012 SlimDX Group")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is
exposed to COM
+[assembly: Guid("d63231bd-800e-4b32-ab04-ea2bd60b5f7b")]
+
+// Version information for an assembly consists of the following four
values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and
Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: NeutralResourcesLanguageAttribute("en-US")]
=======================================
--- /dev/null
+++ /branches/lite/SlimDX.Toolkit/SlimDX.Toolkit.csproj Sat Mar 17 21:28:36
2012
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)'
== '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{76AF8FE8-36E6-4C5A-8D06-B45F93747563}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>SlimDX.Toolkit</RootNamespace>
+ <AssemblyName>SlimDX.Toolkit</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|
AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|
AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <DocumentationFile>bin\Release\SlimDX.Toolkit.XML</DocumentationFile>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Sprites\SpriteContextResources.cs" />
+ <Compile Include="Sprites\SpriteDeviceResources.cs" />
+ <Compile Include="Sprites\SpriteShaders.cs" />
+ <Compile Include="Utilities\SharedResourcePool.cs" />
+ <Compile Include="Sprites\SpriteBatch.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\build\SlimDX.vcxproj">
+ <Project>{8ECCE443-0440-40F4-A94C-F02E027282C3}</Project>
+ <Name>SlimDX</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\SlimMath\SlimMath.csproj">
+ <Project>{820FE441-822F-4519-994B-04F1DE27FF15}</Project>
+ <Name>SlimMath</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <Folder Include="VertexTypes\" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the
targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
=======================================
--- /dev/null
+++ /branches/lite/SlimDX.Toolkit/Sprites/SpriteBatch.cs Sat Mar 17
21:28:36 2012
@@ -0,0 +1,159 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using SlimDX.Direct3D11;
+using SlimMath;
+
+namespace SlimDX.Toolkit
+{
+ /// <summary>
+ /// Specifies various sorting methods for sprite rendering.
+ /// </summary>
+ public enum SpriteSortMode
+ {
+ /// <summary>
+ /// Batch all sprites and submit to GPU when <see
cref="SpriteBatch.End"/> is called. Use this sorting mode
+ /// for best performance when manually drawing in texture order.
+ /// </summary>
+ Deferred,
+
+ /// <summary>
+ /// Disables all batching. Each sprite is rendered with its own
draw call.
+ /// </summary>
+ Immediate,
+
+ /// <summary>
+ /// Batch all sprites and sort by texture first before rendering.
+ /// </summary>
+ Texture,
+
+ /// <summary>
+ /// When drawing with multiple depth layers, sort by layer depth
from back to front.
+ /// </summary>
+ BackToFront,
+
+ /// <summary>
+ /// When drawing with multiple depth layers, sort by layer depth
from front to back.
+ /// </summary>
+ FrontToBack
+ }
+
+ /// <summary>
+ /// Specifies various effects that can be applied to sprites.
+ /// </summary>
+ [Flags]
+ public enum SpriteEffects
+ {
+ /// <summary>
+ /// No effects specified.
+ /// </summary>
+ None,
+
+ /// <summary>
+ /// Flip the sprite horizontally.
+ /// </summary>
+ FlipHorizontally,
+
+ /// <summary>
+ /// Flip the sprite vertically.
+ /// </summary>
+ FlipVertically,
+
+ /// <summary>
+ /// Flip the sprite both horizontally and vertically.
+ /// </summary>
+ FlipBoth = FlipHorizontally | FlipVertically
+ }
+
+ /// <summary>
+ /// Provides efficient rendering of batches of sprites.
+ /// </summary>
+ /// <remarks>
+ /// Sprite batches are lightweight, and several can be created
+ /// and rendered to simultaneously to form several batches that can
then be submitted to the device in the desired
+ /// order by calling <see cref="SpriteBatch.End"/>.
+ /// </remarks>
+ public class SpriteBatch
+ {
+ bool started;
+ SpriteSortMode sortMode = SpriteSortMode.Deferred;
+
+ /// <summary>
+ /// The custom blend state to apply to sprites rendered in the
current batch. Set it to <c>null</c> to use the default settings,
+ /// which is to use premultiplied alpha blending.
+ /// </summary>
+ public BlendState BlendState
+ {
+ get;
+ set;
+ }
+
+ /// <summary>
+ /// The custom sampler state to apply to sprites rendered in the
current batch. Set it to <c>null</c> to use the default settings,
+ /// which are linear filtering with clamp addressing.
+ /// </summary>
+ public SamplerState SamplerState
+ {
+ get;
+ set;
+ }
+
+ /// <summary>
+ /// The custom depth-stencil state to apply to sprites rendered in
the current batch. Set it to <c>null</c> to use the default settings,
+ /// which is to not use the depth-buffer.
+ /// </summary>
+ public DepthStencilState DepthStencilState
+ {
+ get;
+ set;
+ }
+
+ /// <summary>
+ /// The custom sampler state to apply to sprites rendered in the
current batch. Set it to <c>null</c> to use the default settings,
+ /// which is to use counter-clockwise culling.
+ /// </summary>
+ public RasterizerState RasterizerState
+ {
+ get;
+ set;
+ }
+
+ /// <summary>
+ /// The transformation matrix to apply to all sprites rendered in
the batch. This allows for global transforms
+ /// such as scaling or translation that apply to an entire scene.
+ /// </summary>
+ public Matrix TransformMatrix
+ {
+ get;
+ set;
+ }
+
+ /// <summary>
+ /// A callback method that can be to set to allow the application
to use custom shaders (which can be handy
+ /// for 2D postprocessing effects such as bloom or blur).
+ /// </summary>
+ public Action CustomShaderSetup
+ {
+ get;
+ set;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="SpriteBatch"/>
class.
+ /// </summary>
+ /// <param name="context">The rendering context.</param>
+ public SpriteBatch(DeviceContext context)
+ {
+ TransformMatrix = Matrix.Identity;
+ }
+
+ public void Begin(SpriteSortMode sortMode)
+ {
+ }
+
+ public void End()
+ {
+ }
+ }
+}
=======================================
--- /dev/null
+++ /branches/lite/SlimDX.Toolkit/Sprites/SpriteContextResources.cs Sat Mar
17 21:28:36 2012
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace SlimDX.Toolkit
+{
+ class SpriteContextResources
+ {
+ }
+}
=======================================
--- /dev/null
+++ /branches/lite/SlimDX.Toolkit/Sprites/SpriteDeviceResources.cs Sat Mar
17 21:28:36 2012
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using SlimDX.Direct3D11;
+using Buffer = SlimDX.Direct3D11.Buffer;
+using SlimDX.D3DCompiler;
+
+namespace SlimDX.Toolkit
+{
+ class SpriteDeviceResources : IDisposable
+ {
+ public VertexShader VertexShader;
+ public PixelShader PixelShader;
+ public InputLayout InputLayout;
+ public Buffer IndexBuffer;
+
+ public SpriteDeviceResources(Device device)
+ {
+ using (var bytecode =
ShaderBytecode.Compile(SpriteShaders.VertexShader, "VS",
device.VertexShaderProfile, ShaderFlags.OptimizationLevel3,
EffectFlags.None))
+ {
+ VertexShader = new VertexShader(device, bytecode);
+ }
+ }
+
+ public void Dispose()
+ {
+ }
+ }
+}
=======================================
--- /dev/null
+++ /branches/lite/SlimDX.Toolkit/Sprites/SpriteShaders.cs Sat Mar 17
21:28:36 2012
@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace SlimDX.Toolkit
+{
+ static class SpriteShaders
+ {
+ public const string VertexShader = @"
+cbuffer Parameters : register(b0)
+{
+ row_major float4x4 MatrixTransform;
+};
+
+void VS(inout float4 color : COLOR0,
+ inout float2 texCoord : TEXCOORD0,
+ inout float4 position : SV_Position)
+{
+ position = mul(position, MatrixTransform);
+}
+";
+
+ public const string PixelShader = @"
+Texture2D<float4> Texture : register(t0);
+sampler TextureSampler : register(s0);
+
+float4 PS(float4 color : COLOR0,
+ float2 texCoord : TEXCOORD0) : SV_Target0
+{
+ return Texture.Sample(TextureSampler, texCoord) * color;
+}
+";
+ }
+}
=======================================
--- /dev/null
+++ /branches/lite/SlimDX.Toolkit/Utilities/SharedResourcePool.cs Sat Mar
17 21:28:36 2012
@@ -0,0 +1,107 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading;
+
+namespace SlimDX.Toolkit
+{
+ /// <summary>
+ /// Provides an interface for reference counted shared resources.
+ /// Call Dispose to release the individual reference on each resource.
When no other references exist,
+ /// the resource will be freed.
+ /// </summary>
+ /// <typeparam name="T">The type of the resource being
shared.</typeparam>
+ public interface ISharedResource<T> : IDisposable where T : IDisposable
+ {
+ /// <summary>
+ /// The shared resource.
+ /// </summary>
+ T Resource { get; }
+ }
+
+ /// <summary>
+ /// Manages a pool of shared resources such that only a single
instance of a given resource is created
+ /// for each unique key. This avoids duplicate resource creation so
that discrete instances can
+ /// share resources such as shaders or vertex buffers.
+ /// </summary>
+ /// <typeparam name="TKey">The type of the key used to map the
resources.</typeparam>
+ /// <typeparam name="TData">The type of the resource being
shared.</typeparam>
+ public class SharedResourcePool<TKey, TData> where TData : IDisposable
+ {
+ class SharedResource : ISharedResource<TData>
+ {
+ public TData Resource
+ {
+ get;
+ set;
+ }
+
+ public TKey Key;
+ public int RefCount;
+ public SharedResourcePool<TKey, TData> Pool;
+
+ public SharedResource(TKey key, TData data,
SharedResourcePool<TKey, TData> pool)
+ {
+ Key = key;
+ Resource = data;
+ Pool = pool;
+ RefCount = 1;
+ }
+
+ public int AddRef()
+ {
+ return Interlocked.Increment(ref RefCount);
+ }
+
+ public void Dispose()
+ {
+ lock (Pool.syncBlock)
+ {
+ RefCount--;
+ if (RefCount < 1)
+ {
+ Pool.map.Remove(Key);
+ Resource.Dispose();
+ }
+ }
+ }
+ }
+
+ Dictionary<TKey, SharedResource> map = new Dictionary<TKey,
SharedResource>();
+ object syncBlock = new object();
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SharedResourcePool&lt;TKey, TData&gt;"/> class.
+ /// </summary>
+ public SharedResourcePool()
+ {
+ }
+
+ /// <summary>
+ /// Creates or retrieves the shared resource data for the given
key.
+ /// </summary>
+ /// <param name="key">The resource key.</param>
+ /// <param name="factory">A factory function used to create the
resource if none exists in the pool for the given key.</param>
+ /// <returns>The created or retrieved resource reference. The user
must call Dispose on this reference when done with the resource.</returns>
+ public ISharedResource<TData> DemandCreate(TKey key, Func<TData>
factory)
+ {
+ lock (syncBlock)
+ {
+ SharedResource resource;
+ if (map.TryGetValue(key, out resource))
+ {
+ if (resource.AddRef() > 1)
+ return resource;
+
+ map.Remove(key);
+ }
+
+ resource = new SharedResource(key, factory(), this);
+ map.Add(key, resource);
+
+ return resource;
+ }
+ }
+ }
+}
=======================================
--- /branches/lite/SlimMath/Color4.cs Sat Mar 17 11:15:48 2012
+++ /branches/lite/SlimMath/Color4.cs Sat Mar 17 21:28:36 2012
@@ -1037,7 +1037,6 @@
}
#endif

-#if WinFormsInterop
/// <summary>
/// Performs an explicit conversion from <see
cref="SlimMath.Color4"/> to <see cref="System.Drawing.Color"/>.
/// </summary>
@@ -1067,6 +1066,5 @@
Blue = (float)value.B / 255f
};
}
-#endif
}
}
=======================================
--- /branches/lite/SlimMath/Rational.cs Sat Mar 17 11:15:48 2012
+++ /branches/lite/SlimMath/Rational.cs Sat Mar 17 21:28:36 2012
@@ -13,6 +13,8 @@
[StructLayout(LayoutKind.Sequential)]
public struct Rational : IEquatable<Rational>
{
+ public static readonly Rational Empty = new Rational(0, 0);
+
/// <summary>
/// Gets or sets the numerator of the rational pair.
/// </summary>
@@ -22,6 +24,27 @@
/// Gets or sets the denominator of the rational pair.
/// </summary>
public int Denominator;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="Rational"/>
structure.
+ /// </summary>
+ /// <param name="numerator">The numerator of the rational
pair.</param>
+ /// <param name="denominator">The denominator of the rational
pair.</param>
+ public Rational(int numerator, int denominator)
+ {
+ Numerator = numerator;
+ Denominator = denominator;
+ }
+
+ /// <summary>
+ /// Performs an explicit conversion from <see cref="Rational"/> to
<see cref="Single" />.
+ /// </summary>
+ /// <param name="value">The value to be converted.</param>
+ /// <returns>The converted value.</returns>
+ public static explicit operator float(Rational value)
+ {
+ return (float)value.Numerator / (float)value.Denominator;
+ }

/// <summary>
/// Tests for equality between two objects.
=======================================
--- /branches/lite/SlimMath/SlimMath.csproj Sat Mar 17 11:15:48 2012
+++ /branches/lite/SlimMath/SlimMath.csproj Sat Mar 17 21:28:36 2012
@@ -44,6 +44,7 @@
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
+ <Reference Include="System.Drawing" />
</ItemGroup>
<ItemGroup>
<Compile Include="BoundingBox.cs" />
=======================================
--- /branches/lite/build/SlimDX.sln Sat Mar 17 12:07:17 2012
+++ /branches/lite/build/SlimDX.sln Sat Mar 17 21:28:36 2012
@@ -5,6 +5,8 @@
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}")
= "SlimMath", "..\SlimMath\SlimMath.csproj", "{820FE441-822F-4519-994B-04F1DE27FF15}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}")
= "SlimDX.Toolkit", "..\SlimDX.Toolkit\SlimDX.Toolkit.csproj", "{76AF8FE8-36E6-4C5A-8D06-B45F93747563}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
@@ -29,6 +31,14 @@
{820FE441-822F-4519-994B-04F1DE27FF15}.Release|x64.Build.0 = Release|Any
CPU
{820FE441-822F-4519-994B-04F1DE27FF15}.Release|x86.ActiveCfg = Release|
Any CPU
{820FE441-822F-4519-994B-04F1DE27FF15}.Release|x86.Build.0 = Release|Any
CPU
+ {76AF8FE8-36E6-4C5A-8D06-B45F93747563}.Debug|x64.ActiveCfg = Debug|Any
CPU
+ {76AF8FE8-36E6-4C5A-8D06-B45F93747563}.Debug|x64.Build.0 = Debug|Any CPU
+ {76AF8FE8-36E6-4C5A-8D06-B45F93747563}.Debug|x86.ActiveCfg = Debug|Any
CPU
+ {76AF8FE8-36E6-4C5A-8D06-B45F93747563}.Debug|x86.Build.0 = Debug|Any CPU
+ {76AF8FE8-36E6-4C5A-8D06-B45F93747563}.Release|x64.ActiveCfg = Release|
Any CPU
+ {76AF8FE8-36E6-4C5A-8D06-B45F93747563}.Release|x64.Build.0 = Release|Any
CPU
+ {76AF8FE8-36E6-4C5A-8D06-B45F93747563}.Release|x86.ActiveCfg = Release|
Any CPU
+ {76AF8FE8-36E6-4C5A-8D06-B45F93747563}.Release|x86.Build.0 = Release|Any
CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
=======================================
--- /branches/lite/build/SlimDX.vcxproj Sat Mar 17 17:27:04 2012
+++ /branches/lite/build/SlimDX.vcxproj Sat Mar 17 21:28:36 2012
@@ -28,23 +28,25 @@
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<CLRSupport>true</CLRSupport>
- <WholeProgramOptimization>true</WholeProgramOptimization>
+ <WholeProgramOptimization>false</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"
Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<CLRSupport>true</CLRSupport>
+ <WholeProgramOptimization>false</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"
Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<CLRSupport>true</CLRSupport>
- <WholeProgramOptimization>true</WholeProgramOptimization>
+ <WholeProgramOptimization>false</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"
Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<CLRSupport>true</CLRSupport>
+ <WholeProgramOptimization>false</WholeProgramOptimization>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
=======================================
--- /branches/lite/source/Utilities.cpp Sat Mar 17 17:27:04 2012
+++ /branches/lite/source/Utilities.cpp Sat Mar 17 21:28:36 2012
@@ -325,7 +325,7 @@
cleanUp = true;
char *result = new char[readLength];
for (int i = 0; i < readLength; i++)
- result[i] = stream->ReadByte();
+ result[i] = (char)stream->ReadByte();

return result;
}
=======================================
--- /branches/lite/source/direct3d11/Device11.cpp Sun Mar 4 15:53:19 2012
+++ /branches/lite/source/direct3d11/Device11.cpp Sat Mar 17 21:28:36 2012
@@ -199,6 +199,43 @@
InternalPointer->SetPrivateData(WKPDID_D3DDebugObjectName, 0, 0);
}
}
+
+ String^ Device::VertexShaderProfile::get()
+ {
+ Direct3D11::FeatureLevel fl = FeatureLevel;
+ if (fl >= Direct3D11::FeatureLevel::Level_11_0)
+ return "vs_5_0";
+ else if (fl >= Direct3D11::FeatureLevel::Level_10_0)
+ return "vs_4_0";
+ else if (fl >= Direct3D11::FeatureLevel::Level_9_3)
+ return "vs_4_0_level_9_3";
+ else
+ return "vs_4_0_level_9_1";
+ }
+
+ String^ Device::PixelShaderProfile::get()
+ {
+ Direct3D11::FeatureLevel fl = FeatureLevel;
+ if (fl >= Direct3D11::FeatureLevel::Level_11_0)
+ return "ps_5_0";
+ else if (fl >= Direct3D11::FeatureLevel::Level_10_0)
+ return "ps_4_0";
+ else if (fl >= Direct3D11::FeatureLevel::Level_9_3)
+ return "ps_4_0_level_9_3";
+ else
+ return "ps_4_0_level_9_1";
+ }
+
+ String^ Device::GeometryShaderProfile::get()
+ {
+ Direct3D11::FeatureLevel fl = FeatureLevel;
+ if (fl >= Direct3D11::FeatureLevel::Level_11_0)
+ return "gs_5_0";
+ else if (fl >= Direct3D11::FeatureLevel::Level_10_0)
+ return "gs_4_0";
+ else
+ return nullptr;
+ }

CounterCapabilities Device::GetCounterCapabilities()
{
=======================================
--- /branches/lite/source/direct3d11/Device11.h Sat Mar 17 11:15:48 2012
+++ /branches/lite/source/direct3d11/Device11.h Sat Mar 17 21:28:36 2012
@@ -115,6 +115,30 @@
System::String^ get();
void set(System::String^ value);
}
+
+ /// <summary>
+ /// Gets the highest supported vertex shader profile string.
+ /// </summary>
+ property System::String^ VertexShaderProfile
+ {
+ System::String^ get();
+ }
+
+ /// <summary>
+ /// Gets the highest supported pixel shader profile string.
+ /// </summary>
+ property System::String^ PixelShaderProfile
+ {
+ System::String^ get();
+ }
+
+ /// <summary>
+ /// Gets the highest supported geometry shader profile string.
+ /// </summary>
+ property System::String^ GeometryShaderProfile
+ {
+ System::String^ get();
+ }

/// <summary>
/// Initializes a new instance of the <see cref="Device"/> class using
the highest supported feature level.
Reply all
Reply to author
Forward
0 new messages