Skip to content

Instantly share code, notes, and snippets.

@evilrat666
Created February 4, 2014 06:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evilrat666/151adaf4ce94ee1a1c68 to your computer and use it in GitHub Desktop.
Save evilrat666/151adaf4ce94ee1a1c68 to your computer and use it in GitHub Desktop.
optimizer bug?
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());
}
{
"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