|
@@ -3,7 +3,7 @@
|
|
|
#include <dxgi1_6.h>
|
|
#include <dxgi1_6.h>
|
|
|
#include <dxgidebug.h>
|
|
#include <dxgidebug.h>
|
|
|
|
|
|
|
|
-#include "Image.h"
|
|
|
|
|
|
|
+#include "Camera3D.h"
|
|
|
#include "d3dx12.h"
|
|
#include "d3dx12.h"
|
|
|
#include "DLLRegister.h"
|
|
#include "DLLRegister.h"
|
|
|
#include "DX12Buffer.h"
|
|
#include "DX12Buffer.h"
|
|
@@ -12,15 +12,15 @@
|
|
|
#include "DX12Shader.h"
|
|
#include "DX12Shader.h"
|
|
|
#include "DX12Texture.h"
|
|
#include "DX12Texture.h"
|
|
|
#include "DX12VertexShader.h"
|
|
#include "DX12VertexShader.h"
|
|
|
-#include "Window.h"
|
|
|
|
|
#include "Globals.h"
|
|
#include "Globals.h"
|
|
|
#include "GraphicsApi.h"
|
|
#include "GraphicsApi.h"
|
|
|
-#include "Camera3D.h"
|
|
|
|
|
|
|
+#include "Image.h"
|
|
|
#include "Model3D.h"
|
|
#include "Model3D.h"
|
|
|
#include "Model3DList.h"
|
|
#include "Model3DList.h"
|
|
|
#include "Shader.h"
|
|
#include "Shader.h"
|
|
|
#include "TextureList.h"
|
|
#include "TextureList.h"
|
|
|
#include "TextureModel.h"
|
|
#include "TextureModel.h"
|
|
|
|
|
+#include "Window.h"
|
|
|
#include "World3D.h"
|
|
#include "World3D.h"
|
|
|
|
|
|
|
|
using namespace Framework;
|
|
using namespace Framework;
|
|
@@ -116,8 +116,6 @@ typedef HRESULT(__stdcall* DXGIGetDebugInterface1Function)(
|
|
|
void DirectX12::initialize(
|
|
void DirectX12::initialize(
|
|
|
NativeWindow* fenster, Vec2<int> backBufferSize, bool fullScreen)
|
|
NativeWindow* fenster, Vec2<int> backBufferSize, bool fullScreen)
|
|
|
{
|
|
{
|
|
|
- if (device)
|
|
|
|
|
- return GraphicsApi::initialize(fenster, backBufferSize, fullScreen);
|
|
|
|
|
GraphicsApi::initialize(fenster, backBufferSize, fullScreen);
|
|
GraphicsApi::initialize(fenster, backBufferSize, fullScreen);
|
|
|
|
|
|
|
|
HINSTANCE dxgiDLL = getDLLRegister()->loadDLL("dxgi.dll", "dxgi.dll");
|
|
HINSTANCE dxgiDLL = getDLLRegister()->loadDLL("dxgi.dll", "dxgi.dll");
|
|
@@ -139,6 +137,7 @@ void DirectX12::initialize(
|
|
|
MB_ICONERROR);
|
|
MB_ICONERROR);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
+ // CreateDXGIFactory2
|
|
|
CreateDXGIFactory2Function createFactory
|
|
CreateDXGIFactory2Function createFactory
|
|
|
= (CreateDXGIFactory2Function)GetProcAddress(
|
|
= (CreateDXGIFactory2Function)GetProcAddress(
|
|
|
dxgiDLL, "CreateDXGIFactory2");
|
|
dxgiDLL, "CreateDXGIFactory2");
|
|
@@ -154,6 +153,7 @@ void DirectX12::initialize(
|
|
|
MB_ICONERROR);
|
|
MB_ICONERROR);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
+ // D3D12CreateDevice
|
|
|
D3D12CreateDeviceFunction createDevice
|
|
D3D12CreateDeviceFunction createDevice
|
|
|
= (D3D12CreateDeviceFunction)GetProcAddress(
|
|
= (D3D12CreateDeviceFunction)GetProcAddress(
|
|
|
d3d12DLL, "D3D12CreateDevice");
|
|
d3d12DLL, "D3D12CreateDevice");
|
|
@@ -168,9 +168,11 @@ void DirectX12::initialize(
|
|
|
MB_ICONERROR);
|
|
MB_ICONERROR);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
+ // D3D12SerializeVersionedRootSignature
|
|
|
PFN_D3D12_SERIALIZE_VERSIONED_ROOT_SIGNATURE d3d12svrsf
|
|
PFN_D3D12_SERIALIZE_VERSIONED_ROOT_SIGNATURE d3d12svrsf
|
|
|
= (PFN_D3D12_SERIALIZE_VERSIONED_ROOT_SIGNATURE)GetProcAddress(
|
|
= (PFN_D3D12_SERIALIZE_VERSIONED_ROOT_SIGNATURE)GetProcAddress(
|
|
|
d3d12DLL, "D3D12SerializeVersionedRootSignature");
|
|
d3d12DLL, "D3D12SerializeVersionedRootSignature");
|
|
|
|
|
+ // D3D12SerializeRootSignature
|
|
|
PFN_D3D12_SERIALIZE_ROOT_SIGNATURE d3d12srsf
|
|
PFN_D3D12_SERIALIZE_ROOT_SIGNATURE d3d12srsf
|
|
|
= (PFN_D3D12_SERIALIZE_ROOT_SIGNATURE)GetProcAddress(
|
|
= (PFN_D3D12_SERIALIZE_ROOT_SIGNATURE)GetProcAddress(
|
|
|
d3d12DLL, "D3D12SerializeRootSignature");
|
|
d3d12DLL, "D3D12SerializeRootSignature");
|
|
@@ -179,11 +181,13 @@ void DirectX12::initialize(
|
|
|
IDXGIInfoQueue* dxgiInfoQueue;
|
|
IDXGIInfoQueue* dxgiInfoQueue;
|
|
|
if (debugDX)
|
|
if (debugDX)
|
|
|
{
|
|
{
|
|
|
|
|
+ // D3D12GetDebugInterface
|
|
|
D3D12GetDebugInterfaceFunction getDebugInterface
|
|
D3D12GetDebugInterfaceFunction getDebugInterface
|
|
|
= (D3D12GetDebugInterfaceFunction)GetProcAddress(
|
|
= (D3D12GetDebugInterfaceFunction)GetProcAddress(
|
|
|
d3d12DLL, "D3D12GetDebugInterface");
|
|
d3d12DLL, "D3D12GetDebugInterface");
|
|
|
if (SUCCEEDED(getDebugInterface(__uuidof(ID3D12Debug), (void**)&debug)))
|
|
if (SUCCEEDED(getDebugInterface(__uuidof(ID3D12Debug), (void**)&debug)))
|
|
|
debug->EnableDebugLayer();
|
|
debug->EnableDebugLayer();
|
|
|
|
|
+ // DXGIGetDebugInterface1
|
|
|
DXGIGetDebugInterface1Function dxgiDebugInterface
|
|
DXGIGetDebugInterface1Function dxgiDebugInterface
|
|
|
= (DXGIGetDebugInterface1Function)GetProcAddress(
|
|
= (DXGIGetDebugInterface1Function)GetProcAddress(
|
|
|
dxgiDLL, "DXGIGetDebugInterface1");
|
|
dxgiDLL, "DXGIGetDebugInterface1");
|
|
@@ -224,6 +228,7 @@ void DirectX12::initialize(
|
|
|
|
|
|
|
|
if (desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE)
|
|
if (desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE)
|
|
|
{
|
|
{
|
|
|
|
|
+ adapter->Release();
|
|
|
// Don't select the Basic Render Driver adapter.
|
|
// Don't select the Basic Render Driver adapter.
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
@@ -245,6 +250,7 @@ void DirectX12::initialize(
|
|
|
Logging::info() << buff;
|
|
Logging::info() << buff;
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
|
|
+ adapter->Release();
|
|
|
}
|
|
}
|
|
|
if (!adapter)
|
|
if (!adapter)
|
|
|
{
|
|
{
|
|
@@ -396,6 +402,7 @@ void DirectX12::initialize(
|
|
|
D3D12_DESCRIPTOR_HEAP_DESC rtvhdesc = {};
|
|
D3D12_DESCRIPTOR_HEAP_DESC rtvhdesc = {};
|
|
|
rtvhdesc.NumDescriptors = 2; // back buffer count
|
|
rtvhdesc.NumDescriptors = 2; // back buffer count
|
|
|
rtvhdesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV;
|
|
rtvhdesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV;
|
|
|
|
|
+ rtvhdesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
|
|
|
res = device->CreateDescriptorHeap(
|
|
res = device->CreateDescriptorHeap(
|
|
|
&rtvhdesc, __uuidof(ID3D12DescriptorHeap), (void**)&rtvHeap);
|
|
&rtvhdesc, __uuidof(ID3D12DescriptorHeap), (void**)&rtvHeap);
|
|
|
if (FAILED(res))
|
|
if (FAILED(res))
|
|
@@ -770,171 +777,6 @@ void DirectX12::initialize(
|
|
|
factory->Release();
|
|
factory->Release();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void DirectX12::update()
|
|
|
|
|
-{
|
|
|
|
|
- if (!device || !swapChain || !directCommandQueue) return;
|
|
|
|
|
- directCommandQueue->flush();
|
|
|
|
|
- copyCommandQueue->flush();
|
|
|
|
|
- computeCommandQueue->flush();
|
|
|
|
|
- modelList->removeAll();
|
|
|
|
|
- HINSTANCE dxgiDLL = getDLLRegister()->loadDLL("dxgi.dll", "dxgi.dll");
|
|
|
|
|
- if (!dxgiDLL)
|
|
|
|
|
- {
|
|
|
|
|
- WMessageBox(fenster->getWindowHandle(),
|
|
|
|
|
- new Text("Fehler"),
|
|
|
|
|
- new Text("dxgi.dll konnte nicht gefunden werden."),
|
|
|
|
|
- MB_ICONERROR);
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- CreateDXGIFactory2Function createFactory
|
|
|
|
|
- = (CreateDXGIFactory2Function)GetProcAddress(
|
|
|
|
|
- dxgiDLL, "CreateDXGIFactory2");
|
|
|
|
|
- if (!createFactory)
|
|
|
|
|
- {
|
|
|
|
|
- getDLLRegister()->releaseDLL("dxgi.dll");
|
|
|
|
|
- WMessageBox(fenster->getWindowHandle(),
|
|
|
|
|
- new Text("Fehler"),
|
|
|
|
|
- new Text("Der Einstiegspunkt CreateDXGIFactory2 fon DXGI konnte "
|
|
|
|
|
- "nicht gefunden werden."),
|
|
|
|
|
- MB_ICONERROR);
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- DXGI_SWAP_CHAIN_DESC swapChainDesc = {};
|
|
|
|
|
- HRESULT res = swapChain->GetDesc(&swapChainDesc);
|
|
|
|
|
- if (FAILED(res))
|
|
|
|
|
- {
|
|
|
|
|
- getDLLRegister()->releaseDLL("dxgi.dll");
|
|
|
|
|
- Logging::error() << "ERROR: GetDesc returned " << res << "\n";
|
|
|
|
|
- WMessageBox(fenster->getWindowHandle(),
|
|
|
|
|
- new Text("Fehler"),
|
|
|
|
|
- new Text("GetDesc ist Fehlgeschlagen."),
|
|
|
|
|
- MB_ICONERROR);
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- IDXGIFactory4* factory;
|
|
|
|
|
- UINT createFactoryFlags = 0;
|
|
|
|
|
-#if defined(_DEBUG)
|
|
|
|
|
- createFactoryFlags = DXGI_CREATE_FACTORY_DEBUG;
|
|
|
|
|
-#endif
|
|
|
|
|
- res = createFactory(
|
|
|
|
|
- createFactoryFlags, __uuidof(IDXGIFactory4), (void**)&factory);
|
|
|
|
|
- if (FAILED(res))
|
|
|
|
|
- {
|
|
|
|
|
- getDLLRegister()->releaseDLL("dxgi.dll");
|
|
|
|
|
- Logging::error() << "ERROR: createFactory returned " << res << "\n";
|
|
|
|
|
- WMessageBox(fenster->getWindowHandle(),
|
|
|
|
|
- new Text("Fehler"),
|
|
|
|
|
- new Text("createFactory ist Fehlgeschlagen."),
|
|
|
|
|
- MB_ICONERROR);
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- for (int i = 0; i < 2; ++i)
|
|
|
|
|
- {
|
|
|
|
|
- backBuffer[i]->Release();
|
|
|
|
|
- backBuffer[i] = 0;
|
|
|
|
|
- }
|
|
|
|
|
- res = swapChain->ResizeBuffers(2,
|
|
|
|
|
- backBufferSize.x,
|
|
|
|
|
- backBufferSize.y,
|
|
|
|
|
- swapChainDesc.BufferDesc.Format,
|
|
|
|
|
- swapChainDesc.Flags);
|
|
|
|
|
- backBufferIndex = swapChain->GetCurrentBackBufferIndex();
|
|
|
|
|
-
|
|
|
|
|
- auto rtvDescriptorSize = device->GetDescriptorHandleIncrementSize(
|
|
|
|
|
- D3D12_DESCRIPTOR_HEAP_TYPE_RTV);
|
|
|
|
|
- D3D12_CPU_DESCRIPTOR_HANDLE rtvHandle(
|
|
|
|
|
- rtvHeap->GetCPUDescriptorHandleForHeapStart());
|
|
|
|
|
-
|
|
|
|
|
- for (int i = 0; i < 2; i++)
|
|
|
|
|
- {
|
|
|
|
|
- ID3D12Resource* backBuffer;
|
|
|
|
|
- res = swapChain->GetBuffer(
|
|
|
|
|
- i, __uuidof(ID3D12Resource), (void**)&backBuffer);
|
|
|
|
|
- if (FAILED(res))
|
|
|
|
|
- {
|
|
|
|
|
- getDLLRegister()->releaseDLL("dxgi.dll");
|
|
|
|
|
- factory->Release();
|
|
|
|
|
- Logging::error() << "ERROR: GetBuffer returned " << res << "\n";
|
|
|
|
|
- WMessageBox(fenster->getWindowHandle(),
|
|
|
|
|
- new Text("Fehler"),
|
|
|
|
|
- new Text("GetBuffer ist Fehlgeschlagen."),
|
|
|
|
|
- MB_ICONERROR);
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- device->CreateRenderTargetView(backBuffer, nullptr, rtvHandle);
|
|
|
|
|
-
|
|
|
|
|
- this->backBuffer[i] = backBuffer;
|
|
|
|
|
-
|
|
|
|
|
- rtvHandle.ptr += rtvDescriptorSize;
|
|
|
|
|
- }
|
|
|
|
|
- getDLLRegister()->releaseDLL("dxgi.dll");
|
|
|
|
|
-
|
|
|
|
|
- delete viewPort;
|
|
|
|
|
- viewPort = new D3D12_VIEWPORT();
|
|
|
|
|
- viewPort->Width = (float)this->backBufferSize.x;
|
|
|
|
|
- viewPort->Height = (float)this->backBufferSize.y;
|
|
|
|
|
- viewPort->MinDepth = 0.0f;
|
|
|
|
|
- viewPort->MaxDepth = 1.0f;
|
|
|
|
|
- viewPort->TopLeftX = 0.0f;
|
|
|
|
|
- viewPort->TopLeftY = 0.0f;
|
|
|
|
|
-
|
|
|
|
|
- depthBuffer->Release();
|
|
|
|
|
-
|
|
|
|
|
- D3D12_CLEAR_VALUE optimizedClearValue = {};
|
|
|
|
|
- optimizedClearValue.Format = DXGI_FORMAT_D32_FLOAT;
|
|
|
|
|
- optimizedClearValue.DepthStencil = {1.0f, 0};
|
|
|
|
|
- CD3DX12_HEAP_PROPERTIES heapProps
|
|
|
|
|
- = CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_DEFAULT);
|
|
|
|
|
- CD3DX12_RESOURCE_DESC heapDesc
|
|
|
|
|
- = CD3DX12_RESOURCE_DESC::Tex2D(DXGI_FORMAT_D32_FLOAT,
|
|
|
|
|
- this->backBufferSize.x,
|
|
|
|
|
- this->backBufferSize.y,
|
|
|
|
|
- 1,
|
|
|
|
|
- 0,
|
|
|
|
|
- 1,
|
|
|
|
|
- 0,
|
|
|
|
|
- D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL);
|
|
|
|
|
- res = device->CreateCommittedResource(&heapProps,
|
|
|
|
|
- D3D12_HEAP_FLAG_NONE,
|
|
|
|
|
- &heapDesc,
|
|
|
|
|
- D3D12_RESOURCE_STATE_DEPTH_WRITE,
|
|
|
|
|
- 0,
|
|
|
|
|
- __uuidof(ID3D12Resource),
|
|
|
|
|
- (void**)&depthBuffer);
|
|
|
|
|
- if (FAILED(res))
|
|
|
|
|
- {
|
|
|
|
|
- factory->Release();
|
|
|
|
|
- Logging::error() << "ERROR: CreateCommittedResource returned " << res
|
|
|
|
|
- << "\n";
|
|
|
|
|
- WMessageBox(fenster->getWindowHandle(),
|
|
|
|
|
- new Text("Fehler"),
|
|
|
|
|
- new Text("CreateCommittedResource ist Fehlgeschlagen."),
|
|
|
|
|
- MB_ICONERROR);
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- D3D12_DEPTH_STENCIL_VIEW_DESC dsv = {};
|
|
|
|
|
- dsv.Format = DXGI_FORMAT_D32_FLOAT;
|
|
|
|
|
- dsv.ViewDimension = D3D12_DSV_DIMENSION_TEXTURE2D;
|
|
|
|
|
- dsv.Texture2D.MipSlice = 0;
|
|
|
|
|
- dsv.Flags = D3D12_DSV_FLAG_NONE;
|
|
|
|
|
-
|
|
|
|
|
- device->CreateDepthStencilView(
|
|
|
|
|
- depthBuffer, &dsv, dsvHeap->GetCPUDescriptorHandleForHeapStart());
|
|
|
|
|
-
|
|
|
|
|
- if (uiTexture) uiTexture->release();
|
|
|
|
|
-
|
|
|
|
|
- Image* renderB = new Image(1);
|
|
|
|
|
- renderB->setAlpha3D(1);
|
|
|
|
|
- renderB->newImage(this->backBufferSize.x, this->backBufferSize.y, 0);
|
|
|
|
|
- uiTexture = createOrGetTexture("_f_Render_Image", renderB);
|
|
|
|
|
-
|
|
|
|
|
- texturModel->setTexture(dynamic_cast<Texture*>(uiTexture->getThis()));
|
|
|
|
|
-
|
|
|
|
|
- factory->Release();
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
void DirectX12::beginFrame(bool fill2D, bool fill3D, int fillColor)
|
|
void DirectX12::beginFrame(bool fill2D, bool fill3D, int fillColor)
|
|
|
{
|
|
{
|
|
|
D3D12_RESOURCE_BARRIER barrier;
|
|
D3D12_RESOURCE_BARRIER barrier;
|
|
@@ -972,117 +814,6 @@ void DirectX12::beginFrame(bool fill2D, bool fill3D, int fillColor)
|
|
|
pixelShader->fillConstBuffer((char*)lc, 4, sizeof(int) * 2);
|
|
pixelShader->fillConstBuffer((char*)lc, 4, sizeof(int) * 2);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void DirectX12::renderObject(Model3D* zObj)
|
|
|
|
|
-{
|
|
|
|
|
- Mat4<float> trans = Mat4<float>::identity();
|
|
|
|
|
- zObj->zModelData()->zDXVertexBuffer()->copyToGPU();
|
|
|
|
|
- zObj->zModelData()->zDXIndexBuffer()->copyToGPU();
|
|
|
|
|
- int anz = zObj->calculateMatrices(trans, matrixBuffer);
|
|
|
|
|
- if (vertexShader)
|
|
|
|
|
- vertexShader->fillConstBuffer(
|
|
|
|
|
- (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->fillConstBuffer(
|
|
|
|
|
- (char*)matirialBuffer, 3, sizeof(float) * 3);
|
|
|
|
|
- unsigned int offset = 0;
|
|
|
|
|
- unsigned int es
|
|
|
|
|
- = (unsigned)zObj->zModelData()->zDXVertexBuffer()->getElementLength();
|
|
|
|
|
- Model3DTexture* zTexture = zObj->zTexture();
|
|
|
|
|
- int ind = 0;
|
|
|
|
|
- zObj->beforeRender(this, vertexShader, pixelShader);
|
|
|
|
|
- for (auto i = zObj->zModelData()->getPolygons(); i; i++)
|
|
|
|
|
- {
|
|
|
|
|
- if (zObj->needRenderPolygon(ind))
|
|
|
|
|
- {
|
|
|
|
|
- Texture* t = zTexture->zPolygonTexture(ind);
|
|
|
|
|
- // if( t &&t->needsUpdate() )
|
|
|
|
|
- // t->updateTextur();
|
|
|
|
|
- DXGI_FORMAT f = DXGI_FORMAT_R32_UINT;
|
|
|
|
|
- if (zObj->zModelData()->zDXIndexBuffer()->getElementLength() == 2)
|
|
|
|
|
- f = DXGI_FORMAT_R16_UINT;
|
|
|
|
|
- if (zObj->zModelData()->zDXIndexBuffer()->getElementLength() == 1)
|
|
|
|
|
- f = DXGI_FORMAT_R8_UINT;
|
|
|
|
|
- indexBufferView->Format = f;
|
|
|
|
|
- if (t)
|
|
|
|
|
- {
|
|
|
|
|
- /*ID3D11ShaderResourceView *v[ 3 ];
|
|
|
|
|
- v[ 0 ] = *(DX11Texture *)t;
|
|
|
|
|
- v[ 1 ] = *diffuseLights;
|
|
|
|
|
- v[ 2 ] = *pointLights;
|
|
|
|
|
- d3d11Context->PSSetShaderResources( 0, 3, v );
|
|
|
|
|
- d3d11Context->DrawIndexed( indexBuffer->getElementCount(), 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
|
|
|
|
|
- = zObj->zModelData()->zDXIndexBuffer()->getElementCount()
|
|
|
|
|
- * zObj->zModelData()->zDXIndexBuffer()->getElementLength();
|
|
|
|
|
- indexBufferView->BufferLocation
|
|
|
|
|
- = ((DX12Buffer*)zObj->zModelData()->zDXIndexBuffer())
|
|
|
|
|
- ->zBuffer()
|
|
|
|
|
- ->GetGPUVirtualAddress();
|
|
|
|
|
- directCommandQueue->getCommandList()->IASetIndexBuffer(
|
|
|
|
|
- indexBufferView);
|
|
|
|
|
- vertexBufferView->SizeInBytes
|
|
|
|
|
- = zObj->zModelData()->zDXVertexBuffer()->getElementCount()
|
|
|
|
|
- * zObj->zModelData()->zDXVertexBuffer()->getElementLength();
|
|
|
|
|
- vertexBufferView->BufferLocation
|
|
|
|
|
- = ((DX12Buffer*)zObj->zModelData()->zDXVertexBuffer())
|
|
|
|
|
- ->zBuffer()
|
|
|
|
|
- ->GetGPUVirtualAddress();
|
|
|
|
|
- directCommandQueue->getCommandList()->IASetVertexBuffers(
|
|
|
|
|
- 0, 1, vertexBufferView);
|
|
|
|
|
- directCommandQueue->getCommandList()->IASetPrimitiveTopology(
|
|
|
|
|
- D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
|
|
|
|
- directCommandQueue->getCommandList()->DrawIndexedInstanced(
|
|
|
|
|
- zObj->zModelData()->zDXIndexBuffer()->getElementCount(),
|
|
|
|
|
- 1,
|
|
|
|
|
- 0,
|
|
|
|
|
- 0,
|
|
|
|
|
- 0);
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- /*d3d11Context->RSSetState( meshRS );
|
|
|
|
|
- ID3D11ShaderResourceView *v[ 3 ];
|
|
|
|
|
- v[ 0 ] = *(DX11Texture *)defaultTexture;
|
|
|
|
|
- v[ 1 ] = *diffuseLights;
|
|
|
|
|
- v[ 2 ] = *pointLights;
|
|
|
|
|
- d3d11Context->PSSetShaderResources( 0, 3, v );
|
|
|
|
|
- d3d11Context->DrawIndexed( indexBuffer->getElementCount(), 0, 0
|
|
|
|
|
- ); d3d11Context->RSSetState( texturRS );*/
|
|
|
|
|
- // directCommandQueue->getCommandList()->DrawIndexedInstanced(
|
|
|
|
|
- // indexBuffer->getElementCount(), 1, 0, 0, 0 );
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- ind++;
|
|
|
|
|
- }
|
|
|
|
|
- zObj->afterRender(this, pixelShader, vertexShader);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
// Checks whether a sphere is in the visible space of the world and
|
|
// Checks whether a sphere is in the visible space of the world and
|
|
|
// needs to be drawn
|
|
// needs to be drawn
|
|
|
// pos: The center of the sphere
|
|
// pos: The center of the sphere
|
|
@@ -1201,7 +932,8 @@ Texture* DirectX12::createOrGetTexture(const char* name, Image* b)
|
|
|
if (b) ret->setImageZ(b);
|
|
if (b) ret->setImageZ(b);
|
|
|
return ret;
|
|
return ret;
|
|
|
}
|
|
}
|
|
|
- Texture* ret = new DX12Texture(device, copyCommandQueue, directCommandQueue);
|
|
|
|
|
|
|
+ Texture* ret
|
|
|
|
|
+ = new DX12Texture(device, copyCommandQueue, directCommandQueue);
|
|
|
if (b) ret->setImageZ(b);
|
|
if (b) ret->setImageZ(b);
|
|
|
texturRegister->addTexture(dynamic_cast<Texture*>(ret->getThis()), name);
|
|
texturRegister->addTexture(dynamic_cast<Texture*>(ret->getThis()), name);
|
|
|
ret->updateTextur();
|
|
ret->updateTextur();
|
|
@@ -1299,18 +1031,6 @@ bool DirectX12::isAvailable()
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-DXBuffer* DirectX12::createIndexBuffer()
|
|
|
|
|
-{
|
|
|
|
|
- return new DX12IndexBuffer(
|
|
|
|
|
- sizeof(int), device, copyCommandQueue, directCommandQueue);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-DXBuffer* DirectX12::createVertexBuffer()
|
|
|
|
|
-{
|
|
|
|
|
- return new DX12VertexBuffer(
|
|
|
|
|
- sizeof(Vertex3D), device, copyCommandQueue, directCommandQueue);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
DXBuffer* DirectX12::createStructuredBuffer(int eSize)
|
|
DXBuffer* DirectX12::createStructuredBuffer(int eSize)
|
|
|
{
|
|
{
|
|
|
throw "Sorry, support for structured buffers will come eventualy"; // TODO:
|
|
throw "Sorry, support for structured buffers will come eventualy"; // TODO:
|