sharpdx / SharpDX

SharpDX GitHub Repository
http://sharpdx.org
MIT License
1.7k stars 639 forks source link

Proposal: Project restructure to ease DirectX component versioning #796

Open prasannavl opened 8 years ago

prasannavl commented 8 years ago

Currently, SharpDX project structure mainly revolves around DirectX components. However, each component of DirectX has it own versioning. SharpDX unfortunately, ends up wrapping them all as one blob. And DirectX doesn't make this easy, since the interface naming is unfortunately, meaningless. For example, ID3D1Device can have the suffixes 1, 2, and 3. But they carry no meaning. They could have all been introduced it in the same version, or may indicate the next version.

In C++, its easy to target a platform and a version, since the headers files, in most scenarios differ. But in SharpDX, this ends up being a nightmare.

Some of the most common interfaces that I use, I ended up forming a simple text table, that looks like this to refer to.

Source: https://github.com/prasannavl/WinApi/blob/master/WinApi.DxUtils/DxVersionInfo.txt

/**
 * D2D Common Interfaces:
 * ====
 * Platforms:
 * ----
 * v1.0 - Win 7+
 * v1.1 - Win 7 (Platform Update)+, Win 8+
 * v1.2 - Win 8.1+
 * v1.3 - Win 10+
 * ----
 * 
 * v1.0 - Factory, Bitmap, BitmapBrush
 * v1.1 - Factory1, Device, DeviceContext, Bitmap1, BitmapBrush1
 * v1.2 - Factory2, Device1, DeviceContext1
 * v1.3 - Factory3, Factory4, Factory5, Device2, Device3, Device4, DeviceContext2, DeviceContext3, DeviceContext4
 *  ......
(See link for the full document)
 */

Obviously, its painful. This would be far simpler, if instead, SharpDX separated its components into different projects to form a structure that realizes this.

`SharpDX.dll` - Core libary
`SharpDX.DXGI.dll` - Core DXGI + v1.0
`SharpDX.DXGI-1.1.dll` - DXGI v1.1 (Dependency on both the above)

So, now the interfaces are cleanly tucked away. And if someone is to target a particular platform, all that the library has are the correct interfaces for the particular platform.

Multiple binaries shouldn't be much of an issue, since it can be ILMerged from the developer side should it be a problem.