-
-
Save evilrat666/151adaf4ce94ee1a1c68 to your computer and use it in GitHub Desktop.
optimizer bug?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module util.device; | |
import directx.d3d11; | |
import directx.dxgi; | |
IGraphicsDevice[] GetDevices() | |
{ | |
size_t numAdapters; | |
IDXGIFactory fact; | |
IDXGIAdapter temp; | |
IGraphicsDevice[] devices; | |
assert( SUCCEEDED( CreateDXGIFactory(&IID_IDXGIFactory, cast(void**)&fact) )); | |
while( fact.EnumAdapters(cast(UINT)numAdapters, &temp) != DXGI_ERROR_NOT_FOUND ) // optimizer error: dereferencing null pointer | |
{ | |
IGraphicsDevice device = new GraphicsDeviceD3D(temp); | |
devices ~= device; | |
++numAdapters; | |
} | |
return devices; | |
} | |
IGraphicsDevice GetDefaultDevice() | |
{ | |
return GetDevices()[0]; | |
} | |
abstract class IGraphicsDevice | |
{ | |
} | |
class GraphicsDeviceD3D : IGraphicsDevice | |
{ | |
private this(IDXGIAdapter adapter) { dxgiAdapter = adapter; } | |
package ID3D11Device d3dDevice; | |
package IDXGIAdapter dxgiAdapter; | |
} | |
unittest | |
{ | |
auto device = GetDefaultDevice(); | |
assert(device); | |
} | |
void main() | |
{ | |
import std.stdio; | |
writeln(GetDefaultDevice()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "optbug", | |
"description": "bug", | |
"copyright": "Copyright © 2014, evilrat", | |
"authors": ["evilrat"], | |
"dependencies": { | |
"directx-d": "~master" | |
}, | |
"libs": ["phobos64", "d3d11", "dxgi", "user32", "kernel32"], | |
"dflags": ["-m64"], | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment