[slimdx] r2177 committed - Added caching of D3D11 immediate context. The property overhead was an...

0 views
Skip to first unread message

sli...@googlecode.com

unread,
Mar 4, 2012, 6:56:45 PM3/4/12
to slimdx...@googlegroups.com
Revision: 2177
Author: mike.popoloski
Date: Sun Mar 4 15:53:19 2012
Log: Added caching of D3D11 immediate context. The property overhead
was annoying me.
http://code.google.com/p/slimdx/source/detail?r=2177

Modified:
/trunk/source/direct3d11/Device11.cpp
/trunk/source/direct3d11/Device11.h

=======================================
--- /trunk/source/direct3d11/Device11.cpp Sat Jan 28 10:03:11 2012
+++ /trunk/source/direct3d11/Device11.cpp Sun Mar 4 15:53:19 2012
@@ -93,8 +93,9 @@
if( RECORD_D3D11( hr ).IsFailure )
throw gcnew Direct3D11Exception( Result::Last );

- context->Release();
Construct( device );
+
+ immediateContext = DeviceContext::FromPointer( context, this );
}

SlimDX::DXGI::Factory^ Device::Factory::get()
@@ -148,10 +149,14 @@

DeviceContext^ Device::ImmediateContext::get()
{
- ID3D11DeviceContext *context = NULL;
- InternalPointer->GetImmediateContext( &context );
-
- return DeviceContext::FromPointer( context, this );
+ if (immediateContext == nullptr)
+ {
+ ID3D11DeviceContext *context;
+ InternalPointer->GetImmediateContext(&context);
+ immediateContext = DeviceContext::FromPointer(context, this);
+ }
+
+ return immediateContext;
}

bool Device::IsReferenceDevice::get()
=======================================
--- /trunk/source/direct3d11/Device11.h Sat Jan 28 10:03:11 2012
+++ /trunk/source/direct3d11/Device11.h Sun Mar 4 15:53:19 2012
@@ -50,6 +50,7 @@
COMOBJECT(ID3D11Device, Device);

private:
+ DeviceContext^ immediateContext;
void Initialize( DXGI::Adapter^ adapter, DriverType driverType,
DeviceCreationFlags flags, const D3D_FEATURE_LEVEL *featureLevels, int
count );

public:

Reply all
Reply to author
Forward
0 new messages