|
@@ -120,14 +120,14 @@ DirectX12::~DirectX12()
|
|
|
debug->Release();
|
|
|
}
|
|
|
|
|
|
-typedef HRESULT( __stdcall *CreateDXGIFactory2Function )( UINT, REFIID, void ** );
|
|
|
+typedef HRESULT( __stdcall* CreateDXGIFactory2Function )(UINT, REFIID, void**);
|
|
|
|
|
|
-typedef HRESULT( __stdcall *D3D12CreateDeviceFunction )( IDXGIAdapter *, D3D_FEATURE_LEVEL,
|
|
|
- REFIID, void ** );
|
|
|
+typedef HRESULT( __stdcall* D3D12CreateDeviceFunction )(IDXGIAdapter*, D3D_FEATURE_LEVEL,
|
|
|
+ REFIID, void**);
|
|
|
|
|
|
-typedef HRESULT( __stdcall *D3D12GetDebugInterfaceFunction )( REFIID, void ** );
|
|
|
+typedef HRESULT( __stdcall* D3D12GetDebugInterfaceFunction )(REFIID, void**);
|
|
|
|
|
|
-void DirectX12::initialize( WFenster *fenster, Vec2<int> backBufferSize, bool fullScreen )
|
|
|
+void DirectX12::initialize( WFenster* fenster, Vec2<int> backBufferSize, bool fullScreen )
|
|
|
{
|
|
|
if( device )
|
|
|
return GraphicsApi::initialize( fenster, backBufferSize, fullScreen );
|
|
@@ -172,13 +172,13 @@ void DirectX12::initialize( WFenster *fenster, Vec2<int> backBufferSize, bool fu
|
|
|
debug->EnableDebugLayer();
|
|
|
}
|
|
|
#endif
|
|
|
- IDXGIFactory4 *factory;
|
|
|
+ IDXGIFactory4* factory;
|
|
|
UINT createFactoryFlags = 0;
|
|
|
#if defined(_DEBUG)
|
|
|
if( debugDX )
|
|
|
createFactoryFlags = DXGI_CREATE_FACTORY_DEBUG;
|
|
|
#endif
|
|
|
- HRESULT res = createFactory( createFactoryFlags, __uuidof( IDXGIFactory4 ), (void **)&factory );
|
|
|
+ HRESULT res = createFactory( createFactoryFlags, __uuidof(IDXGIFactory4), (void**)&factory );
|
|
|
if( FAILED( res ) )
|
|
|
{
|
|
|
getDLLRegister()->releaseDLL( "dxgi.dll" );
|
|
@@ -189,19 +189,19 @@ void DirectX12::initialize( WFenster *fenster, Vec2<int> backBufferSize, bool fu
|
|
|
}
|
|
|
int index = 0;
|
|
|
unsigned __int64 maxVideoMemory = 0;
|
|
|
- IDXGIAdapter1 *best = 0;
|
|
|
+ IDXGIAdapter1* best = 0;
|
|
|
do
|
|
|
{
|
|
|
- IDXGIAdapter1 *current;
|
|
|
+ IDXGIAdapter1* current;
|
|
|
res = factory->EnumAdapters1( index++, ¤t );
|
|
|
if( res == S_OK )
|
|
|
{
|
|
|
- ID3D12Device2 *device = 0;
|
|
|
+ ID3D12Device2* device = 0;
|
|
|
DXGI_ADAPTER_DESC1 dxgiAdapterDesc1;
|
|
|
current->GetDesc1( &dxgiAdapterDesc1 );
|
|
|
- if( ( dxgiAdapterDesc1.Flags & DXGI_ADAPTER_FLAG_SOFTWARE ) == 0 &&
|
|
|
+ if( (dxgiAdapterDesc1.Flags & DXGI_ADAPTER_FLAG_SOFTWARE) == 0 &&
|
|
|
dxgiAdapterDesc1.DedicatedVideoMemory > maxVideoMemory &&
|
|
|
- SUCCEEDED( createDevice( current, D3D_FEATURE_LEVEL_12_1, __uuidof( ID3D12Device2 ), (void **)&device ) ) )
|
|
|
+ SUCCEEDED( createDevice( current, D3D_FEATURE_LEVEL_12_1, __uuidof(ID3D12Device2), (void**)&device ) ) )
|
|
|
{
|
|
|
device->Release();
|
|
|
if( best )
|
|
@@ -213,7 +213,7 @@ void DirectX12::initialize( WFenster *fenster, Vec2<int> backBufferSize, bool fu
|
|
|
current->Release();
|
|
|
}
|
|
|
} while( res != DXGI_ERROR_NOT_FOUND );
|
|
|
- res = createDevice( best, D3D_FEATURE_LEVEL_12_0, __uuidof( ID3D12Device2 ), (void **)&device );
|
|
|
+ res = createDevice( best, D3D_FEATURE_LEVEL_12_0, __uuidof(ID3D12Device2), (void**)&device );
|
|
|
best->Release();
|
|
|
if( FAILED( res ) )
|
|
|
{
|
|
@@ -224,7 +224,7 @@ void DirectX12::initialize( WFenster *fenster, Vec2<int> backBufferSize, bool fu
|
|
|
WMessageBox( fenster->getFensterHandle(), new Text( "Fehler" ), new Text( "createDevice ist Fehlgeschlagen." ), MB_ICONERROR );
|
|
|
return;
|
|
|
}
|
|
|
- res = device->QueryInterface( __uuidof( ID3D12InfoQueue ), (void **)&infoQueue );
|
|
|
+ res = device->QueryInterface( __uuidof(ID3D12InfoQueue), (void**)&infoQueue );
|
|
|
if( SUCCEEDED( res ) )
|
|
|
{
|
|
|
infoQueue->SetBreakOnSeverity( D3D12_MESSAGE_SEVERITY_CORRUPTION, TRUE );
|
|
@@ -256,8 +256,8 @@ void DirectX12::initialize( WFenster *fenster, Vec2<int> backBufferSize, bool fu
|
|
|
copyCommandQueue = new DX12CopyCommandQueue( device );
|
|
|
computeCommandQueue = new DX12ComputeCommandQueue( device );
|
|
|
|
|
|
- IDXGIFactory5 *fac5 = 0;
|
|
|
- factory->QueryInterface( __uuidof( IDXGIFactory5 ), (void **)&fac5 );
|
|
|
+ IDXGIFactory5* fac5 = 0;
|
|
|
+ factory->QueryInterface( __uuidof(IDXGIFactory5), (void**)&fac5 );
|
|
|
if( fac5 )
|
|
|
{
|
|
|
res = fac5->CheckFeatureSupport( DXGI_FEATURE_PRESENT_ALLOW_TEARING, &tearing, sizeof( tearing ) );
|
|
@@ -278,7 +278,7 @@ void DirectX12::initialize( WFenster *fenster, Vec2<int> backBufferSize, bool fu
|
|
|
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
|
|
|
swapChainDesc.AlphaMode = DXGI_ALPHA_MODE_IGNORE;
|
|
|
swapChainDesc.Flags = tearing ? DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING : 0;
|
|
|
- IDXGISwapChain1 *tmpSwapChain;
|
|
|
+ IDXGISwapChain1* tmpSwapChain;
|
|
|
res = factory->CreateSwapChainForHwnd( directCommandQueue->getQueue(), fenster->getFensterHandle(), &swapChainDesc, 0, 0, &tmpSwapChain );
|
|
|
if( FAILED( res ) )
|
|
|
{
|
|
@@ -287,7 +287,7 @@ void DirectX12::initialize( WFenster *fenster, Vec2<int> backBufferSize, bool fu
|
|
|
WMessageBox( fenster->getFensterHandle(), new Text( "Fehler" ), new Text( "CreateSwapChainForHwnd ist Fehlgeschlagen." ), MB_ICONERROR );
|
|
|
return;
|
|
|
}
|
|
|
- res = tmpSwapChain->QueryInterface( __uuidof( IDXGISwapChain4 ), (void **)&swapChain );
|
|
|
+ res = tmpSwapChain->QueryInterface( __uuidof(IDXGISwapChain4), (void**)&swapChain );
|
|
|
tmpSwapChain->Release();
|
|
|
if( FAILED( res ) )
|
|
|
{
|
|
@@ -301,7 +301,7 @@ void DirectX12::initialize( WFenster *fenster, Vec2<int> backBufferSize, bool fu
|
|
|
D3D12_DESCRIPTOR_HEAP_DESC rtvhdesc = {};
|
|
|
rtvhdesc.NumDescriptors = 2;
|
|
|
rtvhdesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV;
|
|
|
- res = device->CreateDescriptorHeap( &rtvhdesc, __uuidof( ID3D12DescriptorHeap ), (void **)&rtvHeap );
|
|
|
+ res = device->CreateDescriptorHeap( &rtvhdesc, __uuidof(ID3D12DescriptorHeap), (void**)&rtvHeap );
|
|
|
if( FAILED( res ) )
|
|
|
{
|
|
|
factory->Release();
|
|
@@ -315,8 +315,8 @@ void DirectX12::initialize( WFenster *fenster, Vec2<int> backBufferSize, bool fu
|
|
|
|
|
|
for( int i = 0; i < 2; i++ )
|
|
|
{
|
|
|
- ID3D12Resource *backBuffer;
|
|
|
- res = swapChain->GetBuffer( i, __uuidof( ID3D12Resource ), (void **)&backBuffer );
|
|
|
+ ID3D12Resource* backBuffer;
|
|
|
+ res = swapChain->GetBuffer( i, __uuidof(ID3D12Resource), (void**)&backBuffer );
|
|
|
if( FAILED( res ) )
|
|
|
{
|
|
|
factory->Release();
|
|
@@ -351,13 +351,13 @@ void DirectX12::initialize( WFenster *fenster, Vec2<int> backBufferSize, bool fu
|
|
|
|
|
|
texturModel = new TexturModel();
|
|
|
|
|
|
- Bild *renderB = new Bild( 1 );
|
|
|
+ Bild* renderB = new Bild( 1 );
|
|
|
renderB->setAlpha3D( 1 );
|
|
|
renderB->neuBild( this->backBufferSize.x, this->backBufferSize.y, 0 );
|
|
|
uiTextur = createOrGetTextur( "_f_Render_Bild", renderB );
|
|
|
|
|
|
texturModel->setSize( Vec2<float>( 2.f, 2.f ) );
|
|
|
- texturModel->setTextur( dynamic_cast<Textur *>( uiTextur->getThis() ) );
|
|
|
+ texturModel->setTextur( dynamic_cast<Textur*>(uiTextur->getThis()) );
|
|
|
|
|
|
vertexBufferView = new D3D12_VERTEX_BUFFER_VIEW();
|
|
|
vertexBufferView->StrideInBytes = sizeof( Vertex3D );
|
|
@@ -376,8 +376,8 @@ void DirectX12::initialize( WFenster *fenster, Vec2<int> backBufferSize, bool fu
|
|
|
1, 0, 1, 0, D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL ),
|
|
|
D3D12_RESOURCE_STATE_DEPTH_WRITE,
|
|
|
&optimizedClearValue,
|
|
|
- __uuidof( ID3D12Resource ),
|
|
|
- (void **)&depthBuffer
|
|
|
+ __uuidof(ID3D12Resource),
|
|
|
+ (void**)&depthBuffer
|
|
|
);
|
|
|
if( FAILED( res ) )
|
|
|
{
|
|
@@ -391,7 +391,7 @@ void DirectX12::initialize( WFenster *fenster, Vec2<int> backBufferSize, bool fu
|
|
|
dsvHeapDesc.NumDescriptors = 1;
|
|
|
dsvHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_DSV;
|
|
|
dsvHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
|
|
|
- res = device->CreateDescriptorHeap( &dsvHeapDesc, __uuidof( ID3D12DescriptorHeap ), (void **)&dsvHeap );
|
|
|
+ res = device->CreateDescriptorHeap( &dsvHeapDesc, __uuidof(ID3D12DescriptorHeap), (void**)&dsvHeap );
|
|
|
if( FAILED( res ) )
|
|
|
{
|
|
|
factory->Release();
|
|
@@ -413,7 +413,7 @@ void DirectX12::initialize( WFenster *fenster, Vec2<int> backBufferSize, bool fu
|
|
|
sbheapDesc.NumDescriptors = 6;
|
|
|
sbheapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
|
|
|
sbheapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE;
|
|
|
- res = device->CreateDescriptorHeap( &sbheapDesc, __uuidof( ID3D12DescriptorHeap ), (void **)&shaderBufferHeap );
|
|
|
+ res = device->CreateDescriptorHeap( &sbheapDesc, __uuidof(ID3D12DescriptorHeap), (void**)&shaderBufferHeap );
|
|
|
if( FAILED( res ) )
|
|
|
{
|
|
|
factory->Release();
|
|
@@ -423,12 +423,12 @@ void DirectX12::initialize( WFenster *fenster, Vec2<int> backBufferSize, bool fu
|
|
|
}
|
|
|
|
|
|
vertexShader = new DX12VertexShader( device, copyCommandQueue, directCommandQueue );
|
|
|
- vertexShader->setCompiledByteArray( (unsigned char *)DX12VertexShaderBytes, sizeof( DX12VertexShaderBytes ) );
|
|
|
+ vertexShader->setCompiledByteArray( (unsigned char*)DX12VertexShaderBytes, sizeof( DX12VertexShaderBytes ) );
|
|
|
vertexShader->erstelleConstBuffer( sizeof( Mat4< float > ) * 2, 0 );
|
|
|
vertexShader->erstelleConstBuffer( sizeof( Mat4< float > ) * 128, 1 );
|
|
|
|
|
|
pixelShader = new DX12PixelShader( device, copyCommandQueue, directCommandQueue );
|
|
|
- pixelShader->setCompiledByteArray( (unsigned char *)DX12PixelShaderBytes, sizeof( DX12PixelShaderBytes ) );
|
|
|
+ pixelShader->setCompiledByteArray( (unsigned char*)DX12PixelShaderBytes, sizeof( DX12PixelShaderBytes ) );
|
|
|
pixelShader->erstelleConstBuffer( sizeof( float ) * 4, 2 );
|
|
|
pixelShader->erstelleConstBuffer( sizeof( float ) * 3, 3 );
|
|
|
pixelShader->erstelleConstBuffer( sizeof( int ) * 2, 4 );
|
|
@@ -496,8 +496,8 @@ void DirectX12::initialize( WFenster *fenster, Vec2<int> backBufferSize, bool fu
|
|
|
rootSignatureDescription.Desc_1_1.pStaticSamplers = &sampler;
|
|
|
rootSignatureDescription.Desc_1_1.Flags = rootSignatureFlags;
|
|
|
|
|
|
- ID3DBlob *rootSignature;
|
|
|
- ID3DBlob *error;
|
|
|
+ ID3DBlob* rootSignature;
|
|
|
+ ID3DBlob* error;
|
|
|
res = D3DX12SerializeVersionedRootSignature( &rootSignatureDescription, featureData.HighestVersion, &rootSignature, &error, d3d12svrsf, d3d12srsf );
|
|
|
if( FAILED( res ) )
|
|
|
{
|
|
@@ -509,7 +509,7 @@ void DirectX12::initialize( WFenster *fenster, Vec2<int> backBufferSize, bool fu
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- res = device->CreateRootSignature( 0, rootSignature->GetBufferPointer(), rootSignature->GetBufferSize(), __uuidof( ID3D12RootSignature ), (void **)&signature );
|
|
|
+ res = device->CreateRootSignature( 0, rootSignature->GetBufferPointer(), rootSignature->GetBufferSize(), __uuidof(ID3D12RootSignature), (void**)&signature );
|
|
|
if( FAILED( res ) )
|
|
|
{
|
|
|
factory->Release();
|
|
@@ -577,11 +577,11 @@ void DirectX12::initialize( WFenster *fenster, Vec2<int> backBufferSize, bool fu
|
|
|
vd.Texture2D.MostDetailedMip = 0;
|
|
|
vd.Texture2D.PlaneSlice = 0;
|
|
|
vd.Texture2D.ResourceMinLODClamp = 0;
|
|
|
- device->CreateShaderResourceView( ( (DX12Textur *)uiTextur )->getResource(), &vd, sbHeapHandle );
|
|
|
+ device->CreateShaderResourceView( ((DX12Textur*)uiTextur)->getResource(), &vd, sbHeapHandle );
|
|
|
|
|
|
directCommandQueue->execute();
|
|
|
|
|
|
- res = device->CreateGraphicsPipelineState( &psoDesc, __uuidof( ID3D12PipelineState ), (void **)&pipeline );
|
|
|
+ res = device->CreateGraphicsPipelineState( &psoDesc, __uuidof(ID3D12PipelineState), (void**)&pipeline );
|
|
|
if( FAILED( res ) )
|
|
|
{
|
|
|
factory->Release();
|
|
@@ -622,12 +622,12 @@ void DirectX12::update()
|
|
|
WMessageBox( fenster->getFensterHandle(), new Text( "Fehler" ), new Text( "GetDesc ist Fehlgeschlagen." ), MB_ICONERROR );
|
|
|
return;
|
|
|
}
|
|
|
- IDXGIFactory4 *factory;
|
|
|
+ IDXGIFactory4* factory;
|
|
|
UINT createFactoryFlags = 0;
|
|
|
#if defined(_DEBUG)
|
|
|
createFactoryFlags = DXGI_CREATE_FACTORY_DEBUG;
|
|
|
#endif
|
|
|
- res = createFactory( createFactoryFlags, __uuidof( IDXGIFactory4 ), (void **)&factory );
|
|
|
+ res = createFactory( createFactoryFlags, __uuidof(IDXGIFactory4), (void**)&factory );
|
|
|
if( FAILED( res ) )
|
|
|
{
|
|
|
getDLLRegister()->releaseDLL( "dxgi.dll" );
|
|
@@ -649,8 +649,8 @@ void DirectX12::update()
|
|
|
|
|
|
for( int i = 0; i < 2; i++ )
|
|
|
{
|
|
|
- ID3D12Resource *backBuffer;
|
|
|
- res = swapChain->GetBuffer( i, __uuidof( ID3D12Resource ), (void **)&backBuffer );
|
|
|
+ ID3D12Resource* backBuffer;
|
|
|
+ res = swapChain->GetBuffer( i, __uuidof(ID3D12Resource), (void**)&backBuffer );
|
|
|
if( FAILED( res ) )
|
|
|
{
|
|
|
getDLLRegister()->releaseDLL( "dxgi.dll" );
|
|
@@ -690,8 +690,8 @@ void DirectX12::update()
|
|
|
1, 0, 1, 0, D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL ),
|
|
|
D3D12_RESOURCE_STATE_DEPTH_WRITE,
|
|
|
0,
|
|
|
- __uuidof( ID3D12Resource ),
|
|
|
- (void **)&depthBuffer
|
|
|
+ __uuidof(ID3D12Resource),
|
|
|
+ (void**)&depthBuffer
|
|
|
);
|
|
|
if( FAILED( res ) )
|
|
|
{
|
|
@@ -713,12 +713,12 @@ void DirectX12::update()
|
|
|
if( uiTextur )
|
|
|
uiTextur->release();
|
|
|
|
|
|
- Bild *renderB = new Bild( 1 );
|
|
|
+ Bild* renderB = new Bild( 1 );
|
|
|
renderB->setAlpha3D( 1 );
|
|
|
renderB->neuBild( this->backBufferSize.x, this->backBufferSize.y, 0 );
|
|
|
uiTextur = createOrGetTextur( "_f_Render_Bild", renderB );
|
|
|
|
|
|
- texturModel->setTextur( dynamic_cast<Textur *>( uiTextur->getThis() ) );
|
|
|
+ texturModel->setTextur( dynamic_cast<Textur*>(uiTextur->getThis()) );
|
|
|
|
|
|
factory->Release();
|
|
|
}
|
|
@@ -742,10 +742,10 @@ void DirectX12::beginFrame( bool fill2D, bool fill3D, int fillColor )
|
|
|
{
|
|
|
float color[ 4 ];
|
|
|
// Setup the color to clear the buffer.
|
|
|
- color[ 0 ] = ( ( fillColor >> 16 ) & 0xFF ) / 255.f; // R
|
|
|
- color[ 1 ] = ( ( fillColor >> 8 ) & 0xFF ) / 255.f; // G
|
|
|
- color[ 2 ] = ( fillColor & 0xFF ) / 255.f; // B
|
|
|
- color[ 3 ] = ( ( fillColor >> 24 ) & 0xFF ) / 255.f; // A
|
|
|
+ color[ 0 ] = ((fillColor >> 16) & 0xFF) / 255.f; // R
|
|
|
+ color[ 1 ] = ((fillColor >> 8) & 0xFF) / 255.f; // G
|
|
|
+ color[ 2 ] = (fillColor & 0xFF) / 255.f; // B
|
|
|
+ color[ 3 ] = ((fillColor >> 24) & 0xFF) / 255.f; // A
|
|
|
|
|
|
auto rtvDescriptorSize = device->GetDescriptorHandleIncrementSize( D3D12_DESCRIPTOR_HEAP_TYPE_RTV );
|
|
|
D3D12_CPU_DESCRIPTOR_HANDLE rtv = rtvHeap->GetCPUDescriptorHandleForHeapStart();
|
|
@@ -755,80 +755,83 @@ void DirectX12::beginFrame( bool fill2D, bool fill3D, int fillColor )
|
|
|
directCommandQueue->getCommandList()->ClearRenderTargetView( rtv, color, 0, 0 );
|
|
|
}
|
|
|
int lc[] = { 0, 0 };
|
|
|
- pixelShader->füllConstBuffer( (char *)lc, 4, sizeof( int ) * 2 );
|
|
|
+ pixelShader->füllConstBuffer( (char*)lc, 4, sizeof( int ) * 2 );
|
|
|
}
|
|
|
|
|
|
-void DirectX12::renderObject( Model3D *zObj )
|
|
|
+void DirectX12::renderObject( Model3D* zObj )
|
|
|
{
|
|
|
- vertexBuffer->setData( (void *)texturModel->zVertexBuffer() );
|
|
|
+ vertexBuffer->setData( (void*)texturModel->zVertexBuffer() );
|
|
|
vertexBuffer->setLength( sizeof( Vertex3D ) * texturModel->getVertexAnzahl() );
|
|
|
vertexBuffer->copieren();
|
|
|
Mat4< float > trans = Mat4< float >::identity();
|
|
|
int anz = zObj->errechneMatrizen( trans, matrixBuffer );
|
|
|
if( vertexShader )
|
|
|
- vertexShader->füllConstBuffer( (char *)matrixBuffer, 1, sizeof( Mat4< float > ) * anz );
|
|
|
+ vertexShader->füllConstBuffer( (char*)matrixBuffer, 1, sizeof( Mat4< float > ) * anz );
|
|
|
float matirialBuffer[ 3 ]; // light factors (phong model)
|
|
|
matirialBuffer[ 0 ] = zObj->getAmbientFactor();
|
|
|
matirialBuffer[ 1 ] = zObj->getDiffusFactor();
|
|
|
matirialBuffer[ 2 ] = zObj->getSpecularFactor();
|
|
|
if( pixelShader )
|
|
|
- pixelShader->füllConstBuffer( (char *)matirialBuffer, 3, sizeof( float ) * 3 );
|
|
|
+ pixelShader->füllConstBuffer( (char*)matirialBuffer, 3, sizeof( float ) * 3 );
|
|
|
unsigned int offset = 0;
|
|
|
unsigned int es = (unsigned)vertexBuffer->getElementLength();
|
|
|
- Model3DTextur *zTextur = zObj->zTextur();
|
|
|
+ Model3DTextur* zTextur = zObj->zTextur();
|
|
|
int ind = 0;
|
|
|
for( auto i = zObj->zModelData()->getPolygons(); i; i++ )
|
|
|
{
|
|
|
- indexBuffer->setData( i->indexList );
|
|
|
- indexBuffer->setLength( sizeof( int ) * i->indexAnz );
|
|
|
- indexBuffer->copieren();
|
|
|
- Textur *t = zTextur->zPolygonTextur( ind );
|
|
|
- //if( t &&t->brauchtUpdate() )
|
|
|
- // t->updateTextur();
|
|
|
- DXGI_FORMAT f = DXGI_FORMAT_R32_UINT;
|
|
|
- if( indexBuffer->getElementLength() == 2 )
|
|
|
- f = DXGI_FORMAT_R16_UINT;
|
|
|
- if( indexBuffer->getElementLength() == 1 )
|
|
|
- f = DXGI_FORMAT_R8_UINT;
|
|
|
- indexBufferView->Format = f;
|
|
|
- if( t )
|
|
|
+ if( zObj->needRenderPolygon( ind ) )
|
|
|
{
|
|
|
- /*ID3D11ShaderResourceView *v[ 3 ];
|
|
|
- v[ 0 ] = *(DX11Textur *)t;
|
|
|
- v[ 1 ] = *diffuseLights;
|
|
|
- v[ 2 ] = *pointLights;
|
|
|
- d3d11Context->PSSetShaderResources( 0, 3, v );
|
|
|
- d3d11Context->DrawIndexed( indexBuffer->getElementAnzahl(), 0, 0 );*/
|
|
|
- directCommandQueue->getCommandList()->SetPipelineState( pipeline );
|
|
|
- directCommandQueue->getCommandList()->SetGraphicsRootSignature( signature );
|
|
|
- directCommandQueue->getCommandList()->SetDescriptorHeaps( 1, &shaderBufferHeap );
|
|
|
- directCommandQueue->getCommandList()->SetGraphicsRootDescriptorTable( 0, shaderBufferHeap->GetGPUDescriptorHandleForHeapStart() );
|
|
|
- directCommandQueue->getCommandList()->RSSetViewports( 1, viewPort );
|
|
|
- directCommandQueue->getCommandList()->RSSetScissorRects( 1, allowedRenderArea );
|
|
|
- auto rtvDescriptorSize = device->GetDescriptorHandleIncrementSize( D3D12_DESCRIPTOR_HEAP_TYPE_RTV );
|
|
|
- D3D12_CPU_DESCRIPTOR_HANDLE rtv = rtvHeap->GetCPUDescriptorHandleForHeapStart();
|
|
|
- rtv.ptr += rtvDescriptorSize * backBufferIndex;
|
|
|
- directCommandQueue->getCommandList()->OMSetRenderTargets( 1, &rtv, 0, 0 );
|
|
|
- indexBufferView->SizeInBytes = indexBuffer->getElementAnzahl() * indexBuffer->getElementLength();
|
|
|
- indexBufferView->BufferLocation = indexBuffer->zBuffer()->GetGPUVirtualAddress();
|
|
|
- directCommandQueue->getCommandList()->IASetIndexBuffer( indexBufferView );
|
|
|
- vertexBufferView->SizeInBytes = vertexBuffer->getElementAnzahl() * vertexBuffer->getElementLength();
|
|
|
- vertexBufferView->BufferLocation = vertexBuffer->zBuffer()->GetGPUVirtualAddress();
|
|
|
- directCommandQueue->getCommandList()->IASetVertexBuffers( 0, 1, vertexBufferView );
|
|
|
- directCommandQueue->getCommandList()->IASetPrimitiveTopology( D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST );
|
|
|
- directCommandQueue->getCommandList()->DrawIndexedInstanced( indexBuffer->getElementAnzahl(), 1, 0, 0, 0 );
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- /*d3d11Context->RSSetState( meshRS );
|
|
|
- ID3D11ShaderResourceView *v[ 3 ];
|
|
|
- v[ 0 ] = *(DX11Textur *)defaultTextur;
|
|
|
- v[ 1 ] = *diffuseLights;
|
|
|
- v[ 2 ] = *pointLights;
|
|
|
- d3d11Context->PSSetShaderResources( 0, 3, v );
|
|
|
- d3d11Context->DrawIndexed( indexBuffer->getElementAnzahl(), 0, 0 );
|
|
|
- d3d11Context->RSSetState( texturRS );*/
|
|
|
- //directCommandQueue->getCommandList()->DrawIndexedInstanced( indexBuffer->getElementAnzahl(), 1, 0, 0, 0 );
|
|
|
+ indexBuffer->setData( i->indexList );
|
|
|
+ indexBuffer->setLength( sizeof( int ) * i->indexAnz );
|
|
|
+ indexBuffer->copieren();
|
|
|
+ Textur* t = zTextur->zPolygonTextur( ind );
|
|
|
+ //if( t &&t->brauchtUpdate() )
|
|
|
+ // t->updateTextur();
|
|
|
+ DXGI_FORMAT f = DXGI_FORMAT_R32_UINT;
|
|
|
+ if( indexBuffer->getElementLength() == 2 )
|
|
|
+ f = DXGI_FORMAT_R16_UINT;
|
|
|
+ if( indexBuffer->getElementLength() == 1 )
|
|
|
+ f = DXGI_FORMAT_R8_UINT;
|
|
|
+ indexBufferView->Format = f;
|
|
|
+ if( t )
|
|
|
+ {
|
|
|
+ /*ID3D11ShaderResourceView *v[ 3 ];
|
|
|
+ v[ 0 ] = *(DX11Textur *)t;
|
|
|
+ v[ 1 ] = *diffuseLights;
|
|
|
+ v[ 2 ] = *pointLights;
|
|
|
+ d3d11Context->PSSetShaderResources( 0, 3, v );
|
|
|
+ d3d11Context->DrawIndexed( indexBuffer->getElementAnzahl(), 0, 0 );*/
|
|
|
+ directCommandQueue->getCommandList()->SetPipelineState( pipeline );
|
|
|
+ directCommandQueue->getCommandList()->SetGraphicsRootSignature( signature );
|
|
|
+ directCommandQueue->getCommandList()->SetDescriptorHeaps( 1, &shaderBufferHeap );
|
|
|
+ directCommandQueue->getCommandList()->SetGraphicsRootDescriptorTable( 0, shaderBufferHeap->GetGPUDescriptorHandleForHeapStart() );
|
|
|
+ directCommandQueue->getCommandList()->RSSetViewports( 1, viewPort );
|
|
|
+ directCommandQueue->getCommandList()->RSSetScissorRects( 1, allowedRenderArea );
|
|
|
+ auto rtvDescriptorSize = device->GetDescriptorHandleIncrementSize( D3D12_DESCRIPTOR_HEAP_TYPE_RTV );
|
|
|
+ D3D12_CPU_DESCRIPTOR_HANDLE rtv = rtvHeap->GetCPUDescriptorHandleForHeapStart();
|
|
|
+ rtv.ptr += rtvDescriptorSize * backBufferIndex;
|
|
|
+ directCommandQueue->getCommandList()->OMSetRenderTargets( 1, &rtv, 0, 0 );
|
|
|
+ indexBufferView->SizeInBytes = indexBuffer->getElementAnzahl() * indexBuffer->getElementLength();
|
|
|
+ indexBufferView->BufferLocation = indexBuffer->zBuffer()->GetGPUVirtualAddress();
|
|
|
+ directCommandQueue->getCommandList()->IASetIndexBuffer( indexBufferView );
|
|
|
+ vertexBufferView->SizeInBytes = vertexBuffer->getElementAnzahl() * vertexBuffer->getElementLength();
|
|
|
+ vertexBufferView->BufferLocation = vertexBuffer->zBuffer()->GetGPUVirtualAddress();
|
|
|
+ directCommandQueue->getCommandList()->IASetVertexBuffers( 0, 1, vertexBufferView );
|
|
|
+ directCommandQueue->getCommandList()->IASetPrimitiveTopology( D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST );
|
|
|
+ directCommandQueue->getCommandList()->DrawIndexedInstanced( indexBuffer->getElementAnzahl(), 1, 0, 0, 0 );
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ /*d3d11Context->RSSetState( meshRS );
|
|
|
+ ID3D11ShaderResourceView *v[ 3 ];
|
|
|
+ v[ 0 ] = *(DX11Textur *)defaultTextur;
|
|
|
+ v[ 1 ] = *diffuseLights;
|
|
|
+ v[ 2 ] = *pointLights;
|
|
|
+ d3d11Context->PSSetShaderResources( 0, 3, v );
|
|
|
+ d3d11Context->DrawIndexed( indexBuffer->getElementAnzahl(), 0, 0 );
|
|
|
+ d3d11Context->RSSetState( texturRS );*/
|
|
|
+ //directCommandQueue->getCommandList()->DrawIndexedInstanced( indexBuffer->getElementAnzahl(), 1, 0, 0, 0 );
|
|
|
+ }
|
|
|
}
|
|
|
ind++;
|
|
|
}
|
|
@@ -838,7 +841,7 @@ void DirectX12::renderObject( Model3D *zObj )
|
|
|
// pos: Der Mittelpunkt der Kugel
|
|
|
// radius: Der Radius der Kugel
|
|
|
// dist: Einen Zeiger auf einen float, in dem das quadrat des Abstands zur Kammeraposition gespeichert wird, falls diese Funktion true zurückgiebt und der Zeiger nicht 0 ist
|
|
|
-bool DirectX12::isInFrustrum( const Vec3< float > &pos, float radius, float *dist ) const
|
|
|
+bool DirectX12::isInFrustrum( const Vec3< float >& pos, float radius, float* dist ) const
|
|
|
{
|
|
|
for( int i = 0; i < 6; i++ )
|
|
|
{
|
|
@@ -850,9 +853,9 @@ bool DirectX12::isInFrustrum( const Vec3< float > &pos, float radius, float *dis
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
-void DirectX12::renderKamera( Kam3D *zKamera )
|
|
|
+void DirectX12::renderKamera( Kam3D* zKamera )
|
|
|
{
|
|
|
- directCommandQueue->getCommandList()->RSSetViewports( 1, (D3D12_VIEWPORT *)zKamera->zViewPort() );
|
|
|
+ directCommandQueue->getCommandList()->RSSetViewports( 1, (D3D12_VIEWPORT*)zKamera->zViewPort() );
|
|
|
|
|
|
Mat4< float > tmp = zKamera->getProjectionMatrix() * zKamera->getViewMatrix();
|
|
|
|
|
@@ -893,10 +896,10 @@ void DirectX12::renderKamera( Kam3D *zKamera )
|
|
|
viewAndProj[ 1 ] = zKamera->getProjectionMatrix();
|
|
|
kamPos = zKamera->getWorldPosition();
|
|
|
if( vertexShader )
|
|
|
- vertexShader->füllConstBuffer( (char *)viewAndProj, 0, sizeof( Mat4< float > ) * 2 );
|
|
|
+ vertexShader->füllConstBuffer( (char*)viewAndProj, 0, sizeof( Mat4< float > ) * 2 );
|
|
|
if( pixelShader )
|
|
|
- pixelShader->füllConstBuffer( (char *)&kamPos, 2, sizeof( float ) * 3 );
|
|
|
- Welt3D *w = zKamera->zWelt();
|
|
|
+ pixelShader->füllConstBuffer( (char*)&kamPos, 2, sizeof( float ) * 3 );
|
|
|
+ Welt3D* w = zKamera->zWelt();
|
|
|
w->lock();
|
|
|
for( auto obj = w->getMembers(); obj; obj++ )
|
|
|
{
|
|
@@ -914,7 +917,7 @@ void DirectX12::presentFrame()
|
|
|
viewAndProj[ 0 ] = Mat4<float>::identity();
|
|
|
viewAndProj[ 1 ] = Mat4<float>::identity();
|
|
|
if( vertexShader )
|
|
|
- vertexShader->füllConstBuffer( (char *)viewAndProj, 0, sizeof( Mat4< float > ) * 2 );
|
|
|
+ vertexShader->füllConstBuffer( (char*)viewAndProj, 0, sizeof( Mat4< float > ) * 2 );
|
|
|
|
|
|
uiTextur->updateTextur();
|
|
|
|
|
@@ -939,7 +942,7 @@ void DirectX12::presentFrame()
|
|
|
backBufferIndex = swapChain->GetCurrentBackBufferIndex();
|
|
|
}
|
|
|
|
|
|
-Textur *DirectX12::createOrGetTextur( const char *name, Bild *b )
|
|
|
+Textur* DirectX12::createOrGetTextur( const char* name, Bild* b )
|
|
|
{
|
|
|
if( !device )
|
|
|
{
|
|
@@ -949,22 +952,22 @@ Textur *DirectX12::createOrGetTextur( const char *name, Bild *b )
|
|
|
}
|
|
|
if( texturRegister->hatTextur( name ) )
|
|
|
{
|
|
|
- Textur *ret = texturRegister->getTextur( name );
|
|
|
+ Textur* ret = texturRegister->getTextur( name );
|
|
|
if( b )
|
|
|
ret->setBildZ( b );
|
|
|
return ret;
|
|
|
}
|
|
|
- Textur *ret = new DX12Textur( device, copyCommandQueue, directCommandQueue );
|
|
|
+ Textur* ret = new DX12Textur( device, copyCommandQueue, directCommandQueue );
|
|
|
if( b )
|
|
|
ret->setBildZ( b );
|
|
|
- texturRegister->addTextur( dynamic_cast<Textur *>( ret->getThis() ), name );
|
|
|
+ texturRegister->addTextur( dynamic_cast<Textur*>(ret->getThis()), name );
|
|
|
ret->updateTextur();
|
|
|
copyCommandQueue->execute();
|
|
|
directCommandQueue->execute();
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
-Bild *DirectX12::zUIRenderBild() const
|
|
|
+Bild* DirectX12::zUIRenderBild() const
|
|
|
{
|
|
|
return uiTextur ? uiTextur->zBild() : 0;
|
|
|
}
|
|
@@ -996,16 +999,16 @@ bool DirectX12::isAvailable()
|
|
|
}
|
|
|
#ifdef _DEBUG
|
|
|
D3D12GetDebugInterfaceFunction getDebugInterface = (D3D12GetDebugInterfaceFunction)GetProcAddress( d3d12DLL, "D3D12GetDebugInterface" );
|
|
|
- ID3D12Debug *debug = 0;
|
|
|
- getDebugInterface( __uuidof( ID3D12Debug ), (void **)&debug );
|
|
|
+ ID3D12Debug* debug = 0;
|
|
|
+ getDebugInterface( __uuidof(ID3D12Debug), (void**)&debug );
|
|
|
debug->EnableDebugLayer();
|
|
|
#endif
|
|
|
- IDXGIFactory4 *factory;
|
|
|
+ IDXGIFactory4* factory;
|
|
|
UINT createFactoryFlags = 0;
|
|
|
#ifdef _DEBUG
|
|
|
createFactoryFlags = DXGI_CREATE_FACTORY_DEBUG;
|
|
|
#endif
|
|
|
- HRESULT res = createFactory( createFactoryFlags, __uuidof( IDXGIFactory4 ), (void **)&factory );
|
|
|
+ HRESULT res = createFactory( createFactoryFlags, __uuidof(IDXGIFactory4), (void**)&factory );
|
|
|
if( FAILED( res ) )
|
|
|
{
|
|
|
getDLLRegister()->releaseDLL( "dxgi.dll" );
|
|
@@ -1015,15 +1018,15 @@ bool DirectX12::isAvailable()
|
|
|
int index = 0;
|
|
|
do
|
|
|
{
|
|
|
- IDXGIAdapter1 *current;
|
|
|
+ IDXGIAdapter1* current;
|
|
|
res = factory->EnumAdapters1( index++, ¤t );
|
|
|
if( res == S_OK )
|
|
|
{
|
|
|
DXGI_ADAPTER_DESC1 dxgiAdapterDesc1;
|
|
|
current->GetDesc1( &dxgiAdapterDesc1 );
|
|
|
- ID3D12Device2 *device = 0;
|
|
|
- if( ( dxgiAdapterDesc1.Flags & DXGI_ADAPTER_FLAG_SOFTWARE ) == 0 &&
|
|
|
- SUCCEEDED( createDevice( current, D3D_FEATURE_LEVEL_12_1, __uuidof( ID3D12Device2 ), (void **)&device ) ) )
|
|
|
+ ID3D12Device2* device = 0;
|
|
|
+ if( (dxgiAdapterDesc1.Flags & DXGI_ADAPTER_FLAG_SOFTWARE) == 0 &&
|
|
|
+ SUCCEEDED( createDevice( current, D3D_FEATURE_LEVEL_12_1, __uuidof(ID3D12Device2), (void**)&device ) ) )
|
|
|
{
|
|
|
device->Release();
|
|
|
current->Release();
|