OSDN Git Service

Merge branch 'feature/#36529_SlimDXからSharpDXへの移行' into develop
[dtxmania/dtxmania.git] / SlimDXc_Jun2010(VC++2008) / source / direct3d10 / Device10.cpp
diff --git a/SlimDXc_Jun2010(VC++2008)/source/direct3d10/Device10.cpp b/SlimDXc_Jun2010(VC++2008)/source/direct3d10/Device10.cpp
deleted file mode 100644 (file)
index 6844b32..0000000
+++ /dev/null
@@ -1,362 +0,0 @@
-/*\r
-* Copyright (c) 2007-2010 SlimDX Group\r
-* \r
-* Permission is hereby granted, free of charge, to any person obtaining a copy\r
-* of this software and associated documentation files (the "Software"), to deal\r
-* in the Software without restriction, including without limitation the rights\r
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
-* copies of the Software, and to permit persons to whom the Software is\r
-* furnished to do so, subject to the following conditions:\r
-* \r
-* The above copyright notice and this permission notice shall be included in\r
-* all copies or substantial portions of the Software.\r
-* \r
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
-* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
-* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
-* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
-* THE SOFTWARE.\r
-*/\r
-#include "stdafx.h"\r
-\r
-#include "../DataBox.h"\r
-#include "../stack_array.h"\r
-#include "../dxgi/Adapter.h"\r
-\r
-#include "Direct3D10Exception.h"\r
-\r
-#include "Buffer.h"\r
-#include "CounterCapabilities.h"\r
-#include "CounterDescription.h"\r
-#include "CounterMetadata.h"\r
-#include "DepthStencilView.h"\r
-#include "Device10.h"\r
-#include "Device10_1.h"\r
-#include "InputAssemblerWrapper.h"\r
-#include "InputLayout.h"\r
-#include "OutputMergerWrapper.h"\r
-#include "Predicate.h"\r
-#include "RasterizerWrapper.h"\r
-#include "RenderTargetView.h"\r
-#include "Resource10.h"\r
-#include "ResourceRegion.h"\r
-#include "ShaderResourceView.h"\r
-#include "StreamOutputWrapper.h"\r
-#include "VertexShaderWrapper.h"\r
-#include "PixelShaderWrapper.h"\r
-#include "GeometryShaderWrapper.h"\r
-\r
-using namespace System;\r
-using namespace System::Reflection;\r
-\r
-namespace SlimDX\r
-{\r
-namespace Direct3D10\r
-{\r
-       void Device::InitializeSubclasses()\r
-       {\r
-               m_InputAssembler = gcnew InputAssemblerWrapper( InternalPointer );\r
-               m_OutputMerger = gcnew OutputMergerWrapper( InternalPointer );\r
-               m_StreamOutput = gcnew StreamOutputWrapper( InternalPointer );\r
-               m_Rasterizer = gcnew RasterizerWrapper( InternalPointer );\r
-               m_VertexShader = gcnew VertexShaderWrapper( InternalPointer );\r
-               m_PixelShader = gcnew PixelShaderWrapper( InternalPointer );\r
-               m_GeometryShader = gcnew GeometryShaderWrapper( InternalPointer );\r
-       }\r
-\r
-       Device::Device( ID3D10Device* pointer, ComObject^ owner )\r
-       {\r
-               Construct( pointer, owner );\r
-               InitializeSubclasses();\r
-       }\r
-       \r
-       Device::Device( IntPtr pointer )\r
-       {\r
-               Construct( pointer, NativeInterface );\r
-               InitializeSubclasses();\r
-       }\r
-       \r
-       Device^ Device::FromPointer( ID3D10Device* pointer, ComObject^ owner, ComObjectFlags flags )\r
-       {\r
-               void* pointer1;\r
-               HRESULT hr = pointer->QueryInterface(IID_ID3D10Device1, &pointer1);\r
-               if(SUCCEEDED(hr))\r
-               {\r
-                       pointer->Release();\r
-                       return SlimDX::Direct3D10_1::Device1::FromPointer( static_cast<ID3D10Device1*>( pointer1 ) );\r
-               }\r
-\r
-               return ComObject::ConstructFromPointer<Device,ID3D10Device>( pointer, owner, flags );\r
-       }\r
-       \r
-       Device^ Device::FromPointer( IntPtr pointer )\r
-       {\r
-               ID3D10Device* origPointer = static_cast<ID3D10Device*>( pointer.ToPointer() );\r
-               void* pointer1;\r
-               HRESULT hr = origPointer->QueryInterface(IID_ID3D10Device1, &pointer1);\r
-               if(SUCCEEDED(hr))\r
-               {\r
-                       origPointer->Release();\r
-                       return SlimDX::Direct3D10_1::Device1::FromPointer(pointer);\r
-               }\r
-\r
-               return ComObject::ConstructFromUserPointer<Device>( pointer );\r
-       }\r
-       \r
-       Device::Device( DeviceCreationFlags flags )\r
-       {\r
-               ID3D10Device* device = 0;\r
-               RECORD_D3D10( D3D10CreateDevice( 0, D3D10_DRIVER_TYPE_HARDWARE, 0, static_cast<UINT>( flags ), D3D10_SDK_VERSION, &device ) );\r
-               if( Result::Last.IsFailure )\r
-                       throw gcnew Direct3D10Exception( Result::Last );\r
-               \r
-               Construct( device );\r
-               InitializeSubclasses();\r
-       }\r
-       \r
-       Device::Device( DriverType driverType, DeviceCreationFlags flags )\r
-       {\r
-               ID3D10Device* device = 0;\r
-               RECORD_D3D10( D3D10CreateDevice( 0, static_cast<D3D10_DRIVER_TYPE>( driverType ), 0, static_cast<UINT>( flags ), D3D10_SDK_VERSION, &device ) );\r
-               if( Result::Last.IsFailure )\r
-                       throw gcnew Direct3D10Exception( Result::Last );\r
-               \r
-               Construct( device );\r
-               InitializeSubclasses();\r
-       }\r
-       \r
-       Device::Device( DXGI::Adapter^ adapter, DriverType driverType, DeviceCreationFlags flags )\r
-       {\r
-               IDXGIAdapter* nativeAdapter = adapter == nullptr ? 0 : adapter->InternalPointer;\r
-               ID3D10Device* device = 0;\r
-               RECORD_D3D10( D3D10CreateDevice( nativeAdapter, static_cast<D3D10_DRIVER_TYPE>( driverType ), 0, static_cast<UINT>( flags ), D3D10_SDK_VERSION, &device ) );\r
-               if( Result::Last.IsFailure )\r
-                       throw gcnew Direct3D10Exception( Result::Last );\r
-               \r
-               Construct( device );\r
-               InitializeSubclasses();\r
-       }\r
-\r
-       InputAssemblerWrapper^ Device::InputAssembler::get()\r
-       {\r
-               return m_InputAssembler;\r
-       }\r
-       \r
-       OutputMergerWrapper^ Device::OutputMerger::get()\r
-       {\r
-               return m_OutputMerger;\r
-       }\r
-       \r
-       StreamOutputWrapper^ Device::StreamOutput::get()\r
-       {\r
-               return m_StreamOutput;\r
-       }\r
-       \r
-       RasterizerWrapper^ Device::Rasterizer::get()\r
-       {\r
-               return m_Rasterizer;\r
-       }\r
-\r
-       VertexShaderWrapper^ Device::VertexShader::get()\r
-       {\r
-               return m_VertexShader;\r
-       }\r
-\r
-       PixelShaderWrapper^ Device::PixelShader::get()\r
-       {\r
-               return m_PixelShader;\r
-       }\r
-\r
-       GeometryShaderWrapper^ Device::GeometryShader::get()\r
-       {\r
-               return m_GeometryShader;\r
-       }\r
-       \r
-       DeviceCreationFlags Device::CreationFlags::get()\r
-       {\r
-               return static_cast<DeviceCreationFlags>( InternalPointer->GetCreationFlags() );\r
-       }\r
-\r
-       Result Device::DeviceRemovedReason::get()\r
-       {\r
-               return Result( InternalPointer->GetDeviceRemovedReason() );\r
-       }\r
-       \r
-       CounterCapabilities Device::GetCounterCapabilities()\r
-       {\r
-               D3D10_COUNTER_INFO info;\r
-               InternalPointer->CheckCounterInfo( &info );\r
-               return CounterCapabilities( info );\r
-       }\r
-       \r
-       CounterMetadata Device::GetCounterMetadata( CounterDescription description )\r
-       {\r
-               D3D10_COUNTER_DESC nativeDescription = description.CreateNativeVersion();\r
-               D3D10_COUNTER_TYPE type;\r
-               UINT count = 0;\r
-               UINT nameLength = 0;\r
-               UINT unitsLength = 0;\r
-               UINT descriptionLength = 0;\r
-               if( RECORD_D3D10( InternalPointer->CheckCounter( &nativeDescription, &type, &count, 0, &nameLength, 0, &unitsLength, 0, &descriptionLength ) ).IsFailure )\r
-                       return CounterMetadata();\r
-               \r
-               stack_array<char> nameChars = stackalloc( char, nameLength );\r
-               stack_array<char> unitsChars = stackalloc( char, unitsLength );\r
-               stack_array<char> descriptionChars = stackalloc( char, descriptionLength );\r
-\r
-               if( RECORD_D3D10( InternalPointer->CheckCounter( &nativeDescription, &type, &count, &nameChars[ 0 ], &nameLength, &unitsChars[ 0 ], &unitsLength, &descriptionChars[ 0 ], &descriptionLength ) ).IsFailure )\r
-                       return CounterMetadata();\r
-                       \r
-               return CounterMetadata( static_cast<CounterType>( type ), count, gcnew String( &nameChars[ 0 ] ), gcnew String( &unitsChars[ 0 ] ), gcnew String( &descriptionChars[ 0 ] ) );   \r
-       }\r
-       \r
-       FormatSupport Device::CheckFormatSupport( DXGI::Format format )\r
-       {\r
-               UINT support = 0;\r
-               InternalPointer->CheckFormatSupport( static_cast<DXGI_FORMAT>( format ), &support );\r
-               return static_cast<FormatSupport>( support );\r
-       }\r
-       \r
-       int Device::CheckMultisampleQualityLevels( DXGI::Format format, int sampleCount )\r
-       {\r
-               UINT result = 0;\r
-               InternalPointer->CheckMultisampleQualityLevels( static_cast<DXGI_FORMAT>( format ), sampleCount, &result );\r
-               return result;\r
-       }\r
-\r
-       generic<typename T> where T : ComObject\r
-       T Device::OpenSharedResource(System::IntPtr handle)\r
-       {\r
-               GUID guid = Utilities::GetNativeGuidForType( T::typeid );\r
-               void *resultPointer;\r
-\r
-               HRESULT hr = InternalPointer->OpenSharedResource( handle.ToPointer(), guid, &resultPointer );\r
-               if( RECORD_D3D10( hr ).IsFailure )\r
-                       return T();\r
-\r
-               MethodInfo^ method = T::typeid->GetMethod( "FromPointer", BindingFlags::Public | BindingFlags::Static );\r
-               return safe_cast<T>( method->Invoke( nullptr, gcnew array<Object^> { IntPtr( resultPointer ) } ) );\r
-       }\r
-       \r
-       void Device::ClearDepthStencilView( DepthStencilView^ view, DepthStencilClearFlags flags, float depth, Byte stencil )\r
-       {\r
-               InternalPointer->ClearDepthStencilView( view->InternalPointer, static_cast<UINT>( flags ), depth, stencil );\r
-       }\r
-       \r
-       void Device::ClearRenderTargetView( RenderTargetView^ view, Color4 color )\r
-       {\r
-               const float nativeColor[] = { color.Red, color.Green, color.Blue, color.Alpha };\r
-               InternalPointer->ClearRenderTargetView( view->InternalPointer, nativeColor );\r
-       }\r
-       \r
-       void Device::ClearState()\r
-       {\r
-               InternalPointer->ClearState();\r
-       }\r
-       \r
-       Result Device::ClearAllObjects()\r
-       {\r
-               return RECORD_D3D10( D3DX10UnsetAllDeviceObjects( InternalPointer ) );\r
-       }\r
-       \r
-       void Device::CopyResource( Resource^ source, Resource^ destination )\r
-       {\r
-               InternalPointer->CopyResource( destination->InternalPointer, source->InternalPointer );\r
-       }\r
-       \r
-       void Device::CopySubresourceRegion( Resource^ source, int sourceSubresource, ResourceRegion region, Resource^ destination, int destinationSubresource, int x, int y, int z )\r
-       {\r
-               D3D10_BOX nativeRegion = region.CreateNativeVersion();\r
-               InternalPointer->CopySubresourceRegion( destination->InternalPointer, destinationSubresource, x, y, z, source->InternalPointer, sourceSubresource, &nativeRegion );\r
-       }\r
-       \r
-       void Device::ResolveSubresource( Resource^ source, int sourceSubresource, Resource^ destination, int destinationSubresource, DXGI::Format format )\r
-       {\r
-               InternalPointer->ResolveSubresource( destination->InternalPointer, destinationSubresource, source->InternalPointer, sourceSubresource, static_cast<DXGI_FORMAT>( format ) );\r
-       }\r
-       \r
-       void Device::UpdateSubresource( DataBox^ source, Resource^ resource, int subresource ) \r
-       {\r
-               InternalPointer->UpdateSubresource( resource->InternalPointer, static_cast<UINT>( subresource), 0, source->Data->PositionPointer, source->RowPitch,source->SlicePitch);\r
-       }\r
-\r
-       void Device::UpdateSubresource( DataBox^ source, Resource^ resource, int subresource, ResourceRegion region ) \r
-       {\r
-               D3D10_BOX nativeRegion = region.CreateNativeVersion();\r
-               InternalPointer->UpdateSubresource( resource->InternalPointer, static_cast<UINT>( subresource), &nativeRegion, source->Data->PositionPointer, source->RowPitch,source->SlicePitch);\r
-       }\r
-\r
-       void Device::Draw( int vertexCount, int startVertexLocation )\r
-       {\r
-               InternalPointer->Draw( vertexCount, startVertexLocation );\r
-       }\r
-       \r
-       void Device::DrawInstanced( int vertexCountPerInstance, int instanceCount, int startVertexLocation, int startInstanceLocation )\r
-       {\r
-               InternalPointer->DrawInstanced( vertexCountPerInstance, instanceCount, startVertexLocation, startInstanceLocation );\r
-       }\r
-       \r
-       void Device::DrawIndexed( int indexCount, int startIndexLocation, int baseVertexLocation )\r
-       {\r
-               InternalPointer->DrawIndexed( indexCount, startIndexLocation, baseVertexLocation );\r
-       }\r
-       \r
-       void Device::DrawIndexedInstanced( int indexCountPerInstance, int instanceCount, int startIndexLocation, int baseVertexLocation, int startInstanceLocation )\r
-       {\r
-               InternalPointer->DrawIndexedInstanced( indexCountPerInstance, instanceCount, startIndexLocation, baseVertexLocation, startInstanceLocation );\r
-       }\r
-       \r
-       void Device::DrawAuto()\r
-       {\r
-               InternalPointer->DrawAuto();\r
-       }\r
-       \r
-       void Device::Flush()\r
-       {\r
-               InternalPointer->Flush();\r
-       }\r
-       \r
-       void Device::GenerateMips( ShaderResourceView^ view )\r
-       {\r
-               InternalPointer->GenerateMips( view->InternalPointer );\r
-       }\r
-\r
-       void Device::GetPredication( [Out] Predicate^ %predicate, bool %predicateValue )\r
-       {\r
-               ID3D10Predicate* pointer;\r
-               BOOL value;\r
-\r
-               InternalPointer->GetPredication( &pointer, &value );\r
-\r
-               predicate = Predicate::FromPointer( pointer );\r
-               predicateValue = value > 0;\r
-       }\r
-\r
-       void Device::SetPredication( Predicate^ predicate, bool predicateValue )\r
-       {\r
-               InternalPointer->SetPredication( predicate->InternalPointer, predicateValue );\r
-       }\r
-       \r
-       Result Device::CreateWithSwapChain( DXGI::Adapter^ adapter, DriverType driverType, DeviceCreationFlags flags, DXGI::SwapChainDescription swapChainDescription, [Out] Device^ %device, [Out] DXGI::SwapChain^ %swapChain )\r
-       {\r
-               IDXGIAdapter* nativeAdapter = adapter == nullptr ? 0 : adapter->InternalPointer;\r
-               ID3D10Device* resultDevice = 0;\r
-               IDXGISwapChain* resultSwapChain = 0;\r
-               DXGI_SWAP_CHAIN_DESC nativeDescription = swapChainDescription.CreateNativeVersion();\r
-               \r
-               if( RECORD_D3D10( D3D10CreateDeviceAndSwapChain( nativeAdapter, static_cast<D3D10_DRIVER_TYPE>( driverType ), 0, static_cast<UINT>( flags ), D3D10_SDK_VERSION, &nativeDescription, &resultSwapChain, &resultDevice ) ).IsSuccess )\r
-               {\r
-                       device = FromPointer( resultDevice );\r
-                       swapChain = DXGI::SwapChain::FromPointer( resultSwapChain );\r
-               }\r
-               else {\r
-                       device = nullptr;\r
-                       swapChain = nullptr;\r
-               }\r
-               \r
-               return Result::Last;\r
-       }\r
-}\r
-}\r