[slimdx] r2174 committed - Fixed class instance getters in D3D11 shader wrappers.

0 views
Skip to first unread message

sli...@googlecode.com

unread,
Mar 3, 2012, 12:04:34 AM3/3/12
to slimdx...@googlegroups.com
Revision: 2174
Author: mike.popoloski
Date: Fri Mar 2 21:03:28 2012
Log: Fixed class instance getters in D3D11 shader wrappers.
http://code.google.com/p/slimdx/source/detail?r=2174

Modified:
/trunk/build/ReleaseNotes.txt
/trunk/source/direct3d11/ComputeShaderWrapper11.cpp
/trunk/source/direct3d11/ComputeShaderWrapper11.h
/trunk/source/direct3d11/DomainShaderWrapper11.cpp
/trunk/source/direct3d11/DomainShaderWrapper11.h
/trunk/source/direct3d11/GeometryShaderWrapper11.cpp
/trunk/source/direct3d11/GeometryShaderWrapper11.h
/trunk/source/direct3d11/HullShaderWrapper11.cpp
/trunk/source/direct3d11/HullShaderWrapper11.h
/trunk/source/direct3d11/PixelShaderWrapper11.cpp
/trunk/source/direct3d11/PixelShaderWrapper11.h
/trunk/source/direct3d11/VertexShaderWrapper11.cpp
/trunk/source/direct3d11/VertexShaderWrapper11.h

=======================================
--- /trunk/build/ReleaseNotes.txt Fri Mar 2 13:11:16 2012
+++ /trunk/build/ReleaseNotes.txt Fri Mar 2 21:03:28 2012
@@ -1,3 +1,6 @@
+Direct3D 11
+ * Fixed shader wrappers to allow getting class instances.
+
DirectWrite
* Changed TextRenderer into ITextRenderer to allow user implementation.
* Added Strikethrough and Underline classes
=======================================
--- /trunk/source/direct3d11/ComputeShaderWrapper11.cpp Sat Jan 28 10:03:11
2012
+++ /trunk/source/direct3d11/ComputeShaderWrapper11.cpp Fri Mar 2 21:03:28
2012
@@ -71,26 +71,20 @@

ComputeShader^ ComputeShaderWrapper::Get()
{
- return Get( nullptr );
+ array<ClassInstance^>^ dummy;
+ return Get( 0, dummy );
}

- ComputeShader^ ComputeShaderWrapper::Get( array<ClassInstance^>^
classInstances )
+ ComputeShader^ ComputeShaderWrapper::Get( int count,
array<ClassInstance^>^ %classInstances )
{
ID3D11ComputeShader *shader = NULL;
- ID3D11ClassInstance** instancePtr = NULL;
- stack_array<ID3D11ClassInstance*> instances;
- UINT count = 0;
-
- if( classInstances != nullptr && classInstances->Length > 0 )
- {
- instances = stack_array<ID3D11ClassInstance*>( classInstances->Length );
- instancePtr = &instances[0];
- count = classInstances->Length;
- }
-
- deviceContext->CSGetShader( &shader, instancePtr, &count );
-
- for( UINT i = 0; i < count; i++ )
+ stack_array<ID3D11ClassInstance*> instances =
stackalloc(ID3D11ClassInstance*, count);
+ UINT uCount = count;
+
+ deviceContext->CSGetShader( &shader, &instances[0], &uCount );
+
+ classInstances = gcnew array<ClassInstance^>(uCount);
+ for( UINT i = 0; i < uCount; i++ )
classInstances[i] = ClassInstance::FromPointer( instances[i] );

return shader == NULL ? nullptr : ComputeShader::FromPointer( shader );
=======================================
--- /trunk/source/direct3d11/ComputeShaderWrapper11.h Sat Jan 28 10:03:11
2012
+++ /trunk/source/direct3d11/ComputeShaderWrapper11.h Fri Mar 2 21:03:28
2012
@@ -21,6 +21,8 @@
*/
#pragma once

+using System::Runtime::InteropServices::OutAttribute;
+
namespace SlimDX
{
namespace Direct3D11
@@ -66,9 +68,10 @@
/// <summary>
/// Gets the compute shader currently assigned to the device.
/// </summary>
+ /// <param name="count">The number of class instances to
retrieve.</param>
/// <param name="classInstances">An array that will be used to contain
any class instances currently active.</param>
/// <returns>The compute shader (null if no shader is
assigned).</returns>
- ComputeShader^ Get( array<ClassInstance^>^ classInstances );
+ ComputeShader^ Get( int count, [Out]
array<ClassInstance^>^ %classInstances );

/// <summary>
/// Gets the constant buffers used by the compute shader stage.
=======================================
--- /trunk/source/direct3d11/DomainShaderWrapper11.cpp Sat Jan 28 10:03:11
2012
+++ /trunk/source/direct3d11/DomainShaderWrapper11.cpp Fri Mar 2 21:03:28
2012
@@ -70,26 +70,20 @@

DomainShader^ DomainShaderWrapper::Get()
{
- return Get( nullptr );
+ array<ClassInstance^>^ dummy;
+ return Get( 0, dummy );
}

- DomainShader^ DomainShaderWrapper::Get( array<ClassInstance^>^
classInstances )
+ DomainShader^ DomainShaderWrapper::Get( int count,
array<ClassInstance^>^ %classInstances )
{
ID3D11DomainShader *shader = NULL;
- ID3D11ClassInstance** instancePtr = NULL;
- stack_array<ID3D11ClassInstance*> instances;
- UINT count = 0;
-
- if( classInstances != nullptr && classInstances->Length > 0 )
- {
- instances = stack_array<ID3D11ClassInstance*>( classInstances->Length );
- instancePtr = &instances[0];
- count = classInstances->Length;
- }
-
- deviceContext->DSGetShader( &shader, instancePtr, &count );
-
- for( UINT i = 0; i < count; i++ )
+ stack_array<ID3D11ClassInstance*> instances =
stackalloc(ID3D11ClassInstance*, count);
+ UINT uCount = count;
+
+ deviceContext->DSGetShader( &shader, &instances[0], &uCount );
+
+ classInstances = gcnew array<ClassInstance^>(uCount);
+ for( UINT i = 0; i < uCount; i++ )
classInstances[i] = ClassInstance::FromPointer( instances[i] );

return shader == NULL ? nullptr : DomainShader::FromPointer( shader );
=======================================
--- /trunk/source/direct3d11/DomainShaderWrapper11.h Sat Jan 28 10:03:11
2012
+++ /trunk/source/direct3d11/DomainShaderWrapper11.h Fri Mar 2 21:03:28
2012
@@ -21,6 +21,8 @@
*/
#pragma once

+using System::Runtime::InteropServices::OutAttribute;
+
namespace SlimDX
{
namespace Direct3D11
@@ -65,9 +67,10 @@
/// <summary>
/// Gets the domain shader currently assigned to the device.
/// </summary>
+ /// <param name="count">The number of class instances to
retrieve.</param>
/// <param name="classInstances">An array that will be used to contain
any class instances currently active.</param>
/// <returns>The domain shader (null if no shader is
assigned).</returns>
- DomainShader^ Get( array<ClassInstance^>^ classInstances );
+ DomainShader^ Get( int count, [Out]
array<ClassInstance^>^ %classInstances );

/// <summary>
/// Gets the constant buffers used by the domain shader stage.
=======================================
--- /trunk/source/direct3d11/GeometryShaderWrapper11.cpp Sat Jan 28
10:03:11 2012
+++ /trunk/source/direct3d11/GeometryShaderWrapper11.cpp Fri Mar 2
21:03:28 2012
@@ -70,26 +70,20 @@

GeometryShader^ GeometryShaderWrapper::Get()
{
- return Get( nullptr );
+ array<ClassInstance^>^ dummy;
+ return Get( 0, dummy );
}

- GeometryShader^ GeometryShaderWrapper::Get( array<ClassInstance^>^
classInstances )
+ GeometryShader^ GeometryShaderWrapper::Get( int count,
array<ClassInstance^>^ %classInstances )
{
ID3D11GeometryShader *shader = NULL;
- ID3D11ClassInstance** instancePtr = NULL;
- stack_array<ID3D11ClassInstance*> instances;
- UINT count = 0;
-
- if( classInstances != nullptr && classInstances->Length > 0 )
- {
- instances = stack_array<ID3D11ClassInstance*>( classInstances->Length );
- instancePtr = &instances[0];
- count = classInstances->Length;
- }
-
- deviceContext->GSGetShader( &shader, instancePtr, &count );
-
- for( UINT i = 0; i < count; i++ )
+ stack_array<ID3D11ClassInstance*> instances =
stackalloc(ID3D11ClassInstance*, count);
+ UINT uCount = count;
+
+ deviceContext->GSGetShader( &shader, &instances[0], &uCount );
+
+ classInstances = gcnew array<ClassInstance^>(uCount);
+ for( UINT i = 0; i < uCount; i++ )
classInstances[i] = ClassInstance::FromPointer( instances[i] );

return shader == NULL ? nullptr : GeometryShader::FromPointer( shader );
=======================================
--- /trunk/source/direct3d11/GeometryShaderWrapper11.h Sat Jan 28 10:03:11
2012
+++ /trunk/source/direct3d11/GeometryShaderWrapper11.h Fri Mar 2 21:03:28
2012
@@ -21,6 +21,8 @@
*/
#pragma once

+using System::Runtime::InteropServices::OutAttribute;
+
namespace SlimDX
{
namespace Direct3D11
@@ -65,9 +67,10 @@
/// <summary>
/// Gets the geometry shader currently assigned to the device.
/// </summary>
+ /// <param name="count">The number of class instances to
retrieve.</param>
/// <param name="classInstances">An array that will be used to contain
any class instances currently active.</param>
/// <returns>The geometry shader (null if no shader is
assigned).</returns>
- GeometryShader^ Get( array<ClassInstance^>^ classInstances );
+ GeometryShader^ Get( int count, [Out]
array<ClassInstance^>^ %classInstances );

/// <summary>
/// Gets the constant buffers used by the geometry shader stage.
=======================================
--- /trunk/source/direct3d11/HullShaderWrapper11.cpp Sat Jan 28 10:03:11
2012
+++ /trunk/source/direct3d11/HullShaderWrapper11.cpp Fri Mar 2 21:03:28
2012
@@ -70,26 +70,20 @@

HullShader^ HullShaderWrapper::Get()
{
- return Get( nullptr );
+ array<ClassInstance^>^ dummy;
+ return Get( 0, dummy );
}

- HullShader^ HullShaderWrapper::Get( array<ClassInstance^>^ classInstances
)
+ HullShader^ HullShaderWrapper::Get( int count,
array<ClassInstance^>^ %classInstances )
{
ID3D11HullShader *shader = NULL;
- ID3D11ClassInstance** instancePtr = NULL;
- stack_array<ID3D11ClassInstance*> instances;
- UINT count = 0;
-
- if( classInstances != nullptr && classInstances->Length > 0 )
- {
- instances = stack_array<ID3D11ClassInstance*>( classInstances->Length );
- instancePtr = &instances[0];
- count = classInstances->Length;
- }
-
- deviceContext->HSGetShader( &shader, instancePtr, &count );
-
- for( UINT i = 0; i < count; i++ )
+ stack_array<ID3D11ClassInstance*> instances =
stackalloc(ID3D11ClassInstance*, count);
+ UINT uCount = count;
+
+ deviceContext->HSGetShader( &shader, &instances[0], &uCount );
+
+ classInstances = gcnew array<ClassInstance^>(uCount);
+ for( UINT i = 0; i < uCount; i++ )
classInstances[i] = ClassInstance::FromPointer( instances[i] );

return shader == NULL ? nullptr : HullShader::FromPointer( shader );
=======================================
--- /trunk/source/direct3d11/HullShaderWrapper11.h Sat Jan 28 10:03:11 2012
+++ /trunk/source/direct3d11/HullShaderWrapper11.h Fri Mar 2 21:03:28 2012
@@ -21,6 +21,8 @@
*/
#pragma once

+using System::Runtime::InteropServices::OutAttribute;
+
namespace SlimDX
{
namespace Direct3D11
@@ -65,9 +67,10 @@
/// <summary>
/// Gets the hull shader currently assigned to the device.
/// </summary>
+ /// <param name="count">The number of class instances to
retrieve.</param>
/// <param name="classInstances">An array that will be used to contain
any class instances currently active.</param>
/// <returns>The hull shader (null if no shader is assigned).</returns>
- HullShader^ Get( array<ClassInstance^>^ classInstances );
+ HullShader^ Get( int count, [Out]
array<ClassInstance^>^ %classInstances );

/// <summary>
/// Gets the constant buffers used by the hull shader stage.
=======================================
--- /trunk/source/direct3d11/PixelShaderWrapper11.cpp Sat Jan 28 10:03:11
2012
+++ /trunk/source/direct3d11/PixelShaderWrapper11.cpp Fri Mar 2 21:03:28
2012
@@ -70,26 +70,20 @@

PixelShader^ PixelShaderWrapper::Get()
{
- return Get( nullptr );
+ array<ClassInstance^>^ dummy;
+ return Get( 0, dummy );
}

- PixelShader^ PixelShaderWrapper::Get( array<ClassInstance^>^
classInstances )
+ PixelShader^ PixelShaderWrapper::Get( int count,
array<ClassInstance^>^ %classInstances )
{
ID3D11PixelShader *shader = NULL;
- ID3D11ClassInstance** instancePtr = NULL;
- stack_array<ID3D11ClassInstance*> instances;
- UINT count = 0;
-
- if( classInstances != nullptr && classInstances->Length > 0 )
- {
- instances = stack_array<ID3D11ClassInstance*>( classInstances->Length );
- instancePtr = &instances[0];
- count = classInstances->Length;
- }
-
- deviceContext->PSGetShader( &shader, instancePtr, &count );
-
- for( UINT i = 0; i < count; i++ )
+ stack_array<ID3D11ClassInstance*> instances =
stackalloc(ID3D11ClassInstance*, count);
+ UINT uCount = count;
+
+ deviceContext->PSGetShader( &shader, &instances[0], &uCount );
+
+ classInstances = gcnew array<ClassInstance^>(uCount);
+ for( UINT i = 0; i < uCount; i++ )
classInstances[i] = ClassInstance::FromPointer( instances[i] );

return shader == NULL ? nullptr : PixelShader::FromPointer( shader );
=======================================
--- /trunk/source/direct3d11/PixelShaderWrapper11.h Sat Jan 28 10:03:11 2012
+++ /trunk/source/direct3d11/PixelShaderWrapper11.h Fri Mar 2 21:03:28 2012
@@ -21,6 +21,8 @@
*/
#pragma once

+using System::Runtime::InteropServices::OutAttribute;
+
namespace SlimDX
{
namespace Direct3D11
@@ -65,9 +67,10 @@
/// <summary>
/// Gets the pixel shader currently assigned to the device.
/// </summary>
+ /// <param name="count">The number of class instances to
retrieve.</param>
/// <param name="classInstances">An array that will be used to contain
any class instances currently active.</param>
/// <returns>The pixel shader (null if no shader is assigned).</returns>
- PixelShader^ Get( array<ClassInstance^>^ classInstances );
+ PixelShader^ Get( int count, [Out]
array<ClassInstance^>^ %classInstances );

/// <summary>
/// Gets the constant buffers used by the pixel shader stage.
=======================================
--- /trunk/source/direct3d11/VertexShaderWrapper11.cpp Sat Jan 28 10:03:11
2012
+++ /trunk/source/direct3d11/VertexShaderWrapper11.cpp Fri Mar 2 21:03:28
2012
@@ -70,26 +70,20 @@

VertexShader^ VertexShaderWrapper::Get()
{
- return Get( nullptr );
+ array<ClassInstance^>^ dummy;
+ return Get( 0, dummy );
}

- VertexShader^ VertexShaderWrapper::Get( array<ClassInstance^>^
classInstances )
+ VertexShader^ VertexShaderWrapper::Get( int count,
array<ClassInstance^>^ %classInstances )
{
ID3D11VertexShader *shader = NULL;
- ID3D11ClassInstance** instancePtr = NULL;
- stack_array<ID3D11ClassInstance*> instances;
- UINT count = 0;
-
- if( classInstances != nullptr && classInstances->Length > 0 )
- {
- instances = stack_array<ID3D11ClassInstance*>( classInstances->Length );
- instancePtr = &instances[0];
- count = classInstances->Length;
- }
-
- deviceContext->VSGetShader( &shader, instancePtr, &count );
-
- for( UINT i = 0; i < count; i++ )
+ stack_array<ID3D11ClassInstance*> instances =
stackalloc(ID3D11ClassInstance*, count);
+ UINT uCount = count;
+
+ deviceContext->VSGetShader( &shader, &instances[0], &uCount );
+
+ classInstances = gcnew array<ClassInstance^>(uCount);
+ for( UINT i = 0; i < uCount; i++ )
classInstances[i] = ClassInstance::FromPointer( instances[i] );

return shader == NULL ? nullptr : VertexShader::FromPointer( shader );
=======================================
--- /trunk/source/direct3d11/VertexShaderWrapper11.h Sat Jan 28 10:03:11
2012
+++ /trunk/source/direct3d11/VertexShaderWrapper11.h Fri Mar 2 21:03:28
2012
@@ -21,6 +21,8 @@
*/
#pragma once

+using System::Runtime::InteropServices::OutAttribute;
+
namespace SlimDX
{
namespace Direct3D11
@@ -65,9 +67,10 @@
/// <summary>
/// Gets the vertex shader currently assigned to the device.
/// </summary>
- /// <param name="classInstances">An array that will be used to contain
any class instances currently active.</param>
+ /// <param name="count">The number of class instances to
retrieve.</param>
+ /// <param name="classInstances">An array that will contain any class
instances currently active.</param>
/// <returns>The vertex shader (null if no shader is
assigned).</returns>
- VertexShader^ Get( array<ClassInstance^>^ classInstances );
+ VertexShader^ Get( int count, [Out]
array<ClassInstance^>^ %classInstances );

/// <summary>
/// Gets the constant buffers used by the vertex shader stage.

Reply all
Reply to author
Forward
0 new messages