2021.11
This commit is contained in:
parent
aab492e2a5
commit
3acc771737
|
@ -114,10 +114,6 @@ void HelloTexturedCubeGame::BaseGame_UnloadContent()
|
|||
{
|
||||
}
|
||||
|
||||
void HelloTexturedCubeGame::BaseGame_HandleInput()
|
||||
{
|
||||
}
|
||||
|
||||
void HelloTexturedCubeGame::BaseGame_Update()
|
||||
{
|
||||
VERUS_QREF_TIMER;
|
||||
|
|
|
@ -44,7 +44,6 @@ namespace verus
|
|||
virtual void BaseGame_UpdateSettings(App::Window::RDesc windowDesc) override;
|
||||
virtual void BaseGame_LoadContent() override;
|
||||
virtual void BaseGame_UnloadContent() override;
|
||||
virtual void BaseGame_HandleInput() override;
|
||||
virtual void BaseGame_Update() override;
|
||||
virtual void BaseGame_Draw() override;
|
||||
};
|
||||
|
|
|
@ -9,7 +9,7 @@ int main(VERUS_MAIN_DEFAULT_ARGS)
|
|||
try
|
||||
{
|
||||
game.Initialize(argc, argv);
|
||||
game.Run();
|
||||
game.Loop();
|
||||
}
|
||||
catch (D::RcRuntimeError e)
|
||||
{
|
||||
|
|
|
@ -85,11 +85,6 @@ void HelloTriangleGame::BaseGame_UnloadContent()
|
|||
{
|
||||
}
|
||||
|
||||
void HelloTriangleGame::BaseGame_HandleInput()
|
||||
{
|
||||
//_stateMachine.HandleInput();
|
||||
}
|
||||
|
||||
void HelloTriangleGame::BaseGame_Update()
|
||||
{
|
||||
//_stateMachine.Update();
|
||||
|
|
|
@ -44,7 +44,6 @@ namespace verus
|
|||
virtual void BaseGame_UpdateSettings(App::Window::RDesc windowDesc) override;
|
||||
virtual void BaseGame_LoadContent() override;
|
||||
virtual void BaseGame_UnloadContent() override;
|
||||
virtual void BaseGame_HandleInput() override;
|
||||
virtual void BaseGame_Update() override;
|
||||
virtual void BaseGame_Draw() override;
|
||||
};
|
||||
|
|
|
@ -9,7 +9,7 @@ int main(VERUS_MAIN_DEFAULT_ARGS)
|
|||
try
|
||||
{
|
||||
game.Initialize(argc, argv);
|
||||
game.Run(false);
|
||||
game.Loop(false);
|
||||
}
|
||||
catch (D::RcRuntimeError e)
|
||||
{
|
||||
|
|
|
@ -67,14 +67,14 @@ void CommandBufferD3D12::Begin()
|
|||
if (FAILED(hr = GetD3DGraphicsCommandList()->Reset(
|
||||
_pOneTimeCommandAllocator ? _pOneTimeCommandAllocator.Get() : pRendererD3D12->GetD3DCommandAllocator(pRendererD3D12->GetRingBufferIndex()),
|
||||
nullptr)))
|
||||
throw VERUS_RUNTIME_ERROR << "Reset(), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "Reset(); hr=" << VERUS_HR(hr);
|
||||
}
|
||||
|
||||
void CommandBufferD3D12::End()
|
||||
{
|
||||
HRESULT hr = 0;
|
||||
if (FAILED(hr = GetD3DGraphicsCommandList()->Close()))
|
||||
throw VERUS_RUNTIME_ERROR << "Close(), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "Close(); hr=" << VERUS_HR(hr);
|
||||
}
|
||||
|
||||
void CommandBufferD3D12::BeginRenderPass(RPHandle renderPassHandle, FBHandle framebufferHandle, std::initializer_list<Vector4> ilClearValues, bool setViewportAndScissor)
|
||||
|
@ -276,11 +276,11 @@ void CommandBufferD3D12::PushConstants(ShaderPtr shader, int offset, int size, c
|
|||
GetD3DGraphicsCommandList()->SetGraphicsRoot32BitConstants(0, size, p, offset);
|
||||
}
|
||||
|
||||
void CommandBufferD3D12::PipelineImageMemoryBarrier(TexturePtr tex, ImageLayout oldLayout, ImageLayout newLayout, Range<int> mipLevels, int arrayLayer)
|
||||
void CommandBufferD3D12::PipelineImageMemoryBarrier(TexturePtr tex, ImageLayout oldLayout, ImageLayout newLayout, Range mipLevels, int arrayLayer)
|
||||
{
|
||||
auto& texD3D12 = static_cast<RTextureD3D12>(*tex);
|
||||
CD3DX12_RESOURCE_BARRIER rb[16];
|
||||
VERUS_RT_ASSERT(mipLevels.GetLength() < VERUS_COUNT_OF(rb));
|
||||
VERUS_RT_ASSERT(mipLevels.GetCount() <= VERUS_COUNT_OF(rb));
|
||||
int index = 0;
|
||||
for (int mip : mipLevels)
|
||||
{
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace verus
|
|||
virtual bool BindDescriptors(ShaderPtr shader, int setNumber, CSHandle complexSetHandle) override;
|
||||
virtual void PushConstants(ShaderPtr shader, int offset, int size, const void* p, ShaderStageFlags stageFlags) override;
|
||||
|
||||
virtual void PipelineImageMemoryBarrier(TexturePtr tex, ImageLayout oldLayout, ImageLayout newLayout, Range<int> mipLevels, int arrayLayer) override;
|
||||
virtual void PipelineImageMemoryBarrier(TexturePtr tex, ImageLayout oldLayout, ImageLayout newLayout, Range mipLevels, int arrayLayer) override;
|
||||
|
||||
virtual void Draw(int vertexCount, int instanceCount, int firstVertex, int firstInstance) override;
|
||||
virtual void DrawIndexed(int indexCount, int instanceCount, int firstIndex, int vertexOffset, int firstInstance) override;
|
||||
|
|
|
@ -16,7 +16,7 @@ void DescriptorHeap::Create(ID3D12Device* pDevice, D3D12_DESCRIPTOR_HEAP_TYPE ty
|
|||
desc.NumDescriptors = count;
|
||||
desc.Flags = shaderVisible ? D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE : D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
|
||||
if (FAILED(hr = pDevice->CreateDescriptorHeap(&desc, IID_PPV_ARGS(&_pDescriptorHeap))))
|
||||
throw VERUS_RUNTIME_ERROR << "CreateDescriptorHeap(), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "CreateDescriptorHeap(); hr=" << VERUS_HR(hr);
|
||||
_hCPUHandleForHeapStart = _pDescriptorHeap->GetCPUDescriptorHandleForHeapStart();
|
||||
_hGPUHandleForHeapStart = _pDescriptorHeap->GetGPUDescriptorHandleForHeapStart();
|
||||
_handleIncrementSize = pDevice->GetDescriptorHandleIncrementSize(desc.Type);
|
||||
|
|
|
@ -104,7 +104,7 @@ void GeometryD3D12::CreateVertexBuffer(int count, int binding)
|
|||
nullptr,
|
||||
&vb._pMaAllocation,
|
||||
IID_PPV_ARGS(&vb._pBuffer))))
|
||||
throw VERUS_RUNTIME_ERROR << "CreateResource(D3D12_HEAP_TYPE_UPLOAD), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "CreateResource(D3D12_HEAP_TYPE_UPLOAD); hr=" << VERUS_HR(hr);
|
||||
vb._pBuffer->SetName(_C(Str::Utf8ToWide(_name + " (Dynamic VB, " + std::to_string(binding) + ")")));
|
||||
|
||||
VERUS_FOR(i, BaseRenderer::s_ringBufferSize)
|
||||
|
@ -126,7 +126,7 @@ void GeometryD3D12::CreateVertexBuffer(int count, int binding)
|
|||
nullptr,
|
||||
&vb._pMaAllocation,
|
||||
IID_PPV_ARGS(&vb._pBuffer))))
|
||||
throw VERUS_RUNTIME_ERROR << "CreateResource(D3D12_HEAP_TYPE_DEFAULT), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "CreateResource(D3D12_HEAP_TYPE_DEFAULT); hr=" << VERUS_HR(hr);
|
||||
vb._pBuffer->SetName(_C(Str::Utf8ToWide(_name + " (VB, " + std::to_string(binding) + ")")));
|
||||
|
||||
vb._bufferView[0].BufferLocation = vb._pBuffer->GetGPUVirtualAddress();
|
||||
|
@ -149,7 +149,7 @@ void GeometryD3D12::UpdateVertexBuffer(const void* p, int binding, PBaseCommandB
|
|||
CD3DX12_RANGE readRange(0, 0);
|
||||
void* pData = nullptr;
|
||||
if (FAILED(hr = vb._pBuffer->Map(0, &readRange, &pData)))
|
||||
throw VERUS_RUNTIME_ERROR << "Map(), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "Map(); hr=" << VERUS_HR(hr);
|
||||
BYTE* pMappedData = static_cast<BYTE*>(pData) + pRendererD3D12->GetRingBufferIndex() * vb._bufferSize;
|
||||
memcpy(pMappedData + offset * elementSize, p, size);
|
||||
vb._pBuffer->Unmap(0, nullptr);
|
||||
|
@ -176,7 +176,7 @@ void GeometryD3D12::UpdateVertexBuffer(const void* p, int binding, PBaseCommandB
|
|||
nullptr,
|
||||
&svb._pMaAllocation,
|
||||
IID_PPV_ARGS(&svb._pBuffer))))
|
||||
throw VERUS_RUNTIME_ERROR << "CreateResource(D3D12_HEAP_TYPE_UPLOAD), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "CreateResource(D3D12_HEAP_TYPE_UPLOAD); hr=" << VERUS_HR(hr);
|
||||
vb._pBuffer->SetName(_C(Str::Utf8ToWide(_name + " (Staging VB, " + std::to_string(binding) + ")")));
|
||||
}
|
||||
|
||||
|
@ -225,7 +225,7 @@ void GeometryD3D12::CreateIndexBuffer(int count)
|
|||
nullptr,
|
||||
&_indexBuffer._pMaAllocation,
|
||||
IID_PPV_ARGS(&_indexBuffer._pBuffer))))
|
||||
throw VERUS_RUNTIME_ERROR << "CreateResource(D3D12_HEAP_TYPE_UPLOAD), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "CreateResource(D3D12_HEAP_TYPE_UPLOAD); hr=" << VERUS_HR(hr);
|
||||
_indexBuffer._pBuffer->SetName(_C(Str::Utf8ToWide(_name + " (Dynamic IB)")));
|
||||
|
||||
VERUS_FOR(i, BaseRenderer::s_ringBufferSize)
|
||||
|
@ -247,7 +247,7 @@ void GeometryD3D12::CreateIndexBuffer(int count)
|
|||
nullptr,
|
||||
&_indexBuffer._pMaAllocation,
|
||||
IID_PPV_ARGS(&_indexBuffer._pBuffer))))
|
||||
throw VERUS_RUNTIME_ERROR << "CreateResource(D3D12_HEAP_TYPE_DEFAULT), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "CreateResource(D3D12_HEAP_TYPE_DEFAULT); hr=" << VERUS_HR(hr);
|
||||
_indexBuffer._pBuffer->SetName(_C(Str::Utf8ToWide(_name + " (IB)")));
|
||||
|
||||
_indexBufferView[0].BufferLocation = _indexBuffer._pBuffer->GetGPUVirtualAddress();
|
||||
|
@ -269,7 +269,7 @@ void GeometryD3D12::UpdateIndexBuffer(const void* p, PBaseCommandBuffer pCB, INT
|
|||
CD3DX12_RANGE readRange(0, 0);
|
||||
void* pData = nullptr;
|
||||
if (FAILED(hr = _indexBuffer._pBuffer->Map(0, &readRange, &pData)))
|
||||
throw VERUS_RUNTIME_ERROR << "Map(), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "Map(); hr=" << VERUS_HR(hr);
|
||||
BYTE* pMappedData = static_cast<BYTE*>(pData) + pRendererD3D12->GetRingBufferIndex() * _indexBuffer._bufferSize;
|
||||
memcpy(pMappedData + offset * elementSize, p, size);
|
||||
_indexBuffer._pBuffer->Unmap(0, nullptr);
|
||||
|
@ -291,7 +291,7 @@ void GeometryD3D12::UpdateIndexBuffer(const void* p, PBaseCommandBuffer pCB, INT
|
|||
nullptr,
|
||||
&_stagingIndexBuffer._pMaAllocation,
|
||||
IID_PPV_ARGS(&_stagingIndexBuffer._pBuffer))))
|
||||
throw VERUS_RUNTIME_ERROR << "CreateResource(D3D12_HEAP_TYPE_UPLOAD), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "CreateResource(D3D12_HEAP_TYPE_UPLOAD); hr=" << VERUS_HR(hr);
|
||||
_stagingIndexBuffer._pBuffer->SetName(_C(Str::Utf8ToWide(_name + " (Staging IB)")));
|
||||
}
|
||||
|
||||
|
|
|
@ -227,7 +227,7 @@ DXGI_FORMAT CGI::ToNativeFormat(ViaUsage usage, ViaType type, int components)
|
|||
return shorts[index];
|
||||
}
|
||||
break;
|
||||
default: throw VERUS_RECOVERABLE << "ToNativeFormat(), ViaType=?";
|
||||
default: throw VERUS_RECOVERABLE << "ToNativeFormat(); ViaType=?";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ void PipelineD3D12::Init(RcPipelineDesc desc)
|
|||
gpsDesc.Flags = D3D12_PIPELINE_STATE_FLAG_NONE;
|
||||
|
||||
if (FAILED(hr = pRendererD3D12->GetD3DDevice()->CreateGraphicsPipelineState(&gpsDesc, IID_PPV_ARGS(&_pPipelineState))))
|
||||
throw VERUS_RUNTIME_ERROR << "CreateGraphicsPipelineState(), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "CreateGraphicsPipelineState(); hr=" << VERUS_HR(hr);
|
||||
_pPipelineState->SetName(_C(Str::Utf8ToWide(String("PipelineState (") + _C(shader.GetSourceName()) + ", " + desc._shaderBranch + ")")));
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ void PipelineD3D12::InitCompute(RcPipelineDesc desc)
|
|||
cpsDesc.Flags = D3D12_PIPELINE_STATE_FLAG_NONE;
|
||||
|
||||
if (FAILED(hr = pRendererD3D12->GetD3DDevice()->CreateComputePipelineState(&cpsDesc, IID_PPV_ARGS(&_pPipelineState))))
|
||||
throw VERUS_RUNTIME_ERROR << "CreateComputePipelineState(), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "CreateComputePipelineState(); hr=" << VERUS_HR(hr);
|
||||
_pPipelineState->SetName(_C(Str::Utf8ToWide(String("PipelineState (") + _C(shader.GetSourceName()) + ", " + desc._shaderBranch + ")")));
|
||||
}
|
||||
|
||||
|
@ -223,7 +223,7 @@ void PipelineD3D12::InitMeshShading(RcPipelineDesc desc)
|
|||
streamDesc.SizeInBytes = sizeof(meshStateStream);
|
||||
streamDesc.pPipelineStateSubobjectStream = &meshStateStream;
|
||||
if (FAILED(hr = pRendererD3D12->GetD3DDevice()->CreatePipelineState(&streamDesc, IID_PPV_ARGS(&_pPipelineState))))
|
||||
throw VERUS_RUNTIME_ERROR << "CreatePipelineState(), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "CreatePipelineState(); hr=" << VERUS_HR(hr);
|
||||
}
|
||||
|
||||
D3D12_SHADER_BYTECODE PipelineD3D12::ToBytecode(ID3DBlob* pBlob)
|
||||
|
|
|
@ -99,7 +99,7 @@ ComPtr<IDXGIFactory7> RendererD3D12::CreateDXGIFactory()
|
|||
flags = DXGI_CREATE_FACTORY_DEBUG;
|
||||
#endif
|
||||
if (FAILED(hr = CreateDXGIFactory2(flags, IID_PPV_ARGS(&pFactory))))
|
||||
throw VERUS_RUNTIME_ERROR << "CreateDXGIFactory2(), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "CreateDXGIFactory2(); hr=" << VERUS_HR(hr);
|
||||
return pFactory;
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,7 @@ ComPtr<IDXGIAdapter4> RendererD3D12::GetAdapter(ComPtr<IDXGIFactory7> pFactory,
|
|||
}
|
||||
|
||||
if (!pAdapter)
|
||||
throw VERUS_RUNTIME_ERROR << "GetAdapter(), adapter not found";
|
||||
throw VERUS_RUNTIME_ERROR << "GetAdapter(); Adapter not found";
|
||||
|
||||
DXGI_ADAPTER_DESC1 adapterDesc = {};
|
||||
pAdapter->GetDesc1(&adapterDesc);
|
||||
|
@ -144,7 +144,7 @@ void RendererD3D12::CreateSwapChainBuffersRTVs()
|
|||
{
|
||||
ComPtr<ID3D12Resource> pBuffer;
|
||||
if (FAILED(hr = _pSwapChain->GetBuffer(i, IID_PPV_ARGS(&pBuffer))))
|
||||
throw VERUS_RUNTIME_ERROR << "GetBuffer(), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "GetBuffer(); hr=" << VERUS_HR(hr);
|
||||
D3D12_RENDER_TARGET_VIEW_DESC desc = {};
|
||||
desc.Format = DXGI_FORMAT_B8G8R8A8_UNORM_SRGB;
|
||||
desc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D;
|
||||
|
@ -175,12 +175,12 @@ void RendererD3D12::InitD3D()
|
|||
if (FAILED(hr))
|
||||
{
|
||||
if (FAILED(hr = pFactory->EnumWarpAdapter(IID_PPV_ARGS(&pAdapter))))
|
||||
throw VERUS_RUNTIME_ERROR << "EnumWarpAdapter(), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "EnumWarpAdapter(); hr=" << VERUS_HR(hr);
|
||||
hr = D3D12CreateDevice(pAdapter.Get(), featureLevel, IID_PPV_ARGS(&_pDevice));
|
||||
}
|
||||
#endif
|
||||
if (FAILED(hr))
|
||||
throw VERUS_RUNTIME_ERROR << "D3D12CreateDevice(), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "D3D12CreateDevice(); hr=" << VERUS_HR(hr);
|
||||
|
||||
VERUS_RT_ASSERT(D3D_FEATURE_LEVEL_11_0 == featureLevel);
|
||||
VERUS_LOG_INFO("Using feature level: 11_0");
|
||||
|
@ -188,7 +188,7 @@ void RendererD3D12::InitD3D()
|
|||
D3D12MA::ALLOCATOR_DESC allocatorDesc = {};
|
||||
allocatorDesc.pDevice = _pDevice.Get();
|
||||
if (FAILED(hr = D3D12MA::CreateAllocator(&allocatorDesc, &_pMaAllocator)))
|
||||
throw VERUS_RUNTIME_ERROR << "CreateAllocator(), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "CreateAllocator(); hr=" << VERUS_HR(hr);
|
||||
|
||||
#if defined(_DEBUG) || defined(VERUS_RELEASE_DEBUG)
|
||||
ComPtr<ID3D12InfoQueue> pInfoQueue;
|
||||
|
@ -232,19 +232,19 @@ void RendererD3D12::InitD3D()
|
|||
case App::Settings::Platform::classic:
|
||||
{
|
||||
if (FAILED(hr = pFactory->CreateSwapChainForHwnd(_pCommandQueue.Get(), wmInfo.info.win.window, &_swapChainDesc, nullptr, nullptr, &pSwapChain1)))
|
||||
throw VERUS_RUNTIME_ERROR << "CreateSwapChainForHwnd(), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "CreateSwapChainForHwnd(); hr=" << VERUS_HR(hr);
|
||||
pFactory->MakeWindowAssociation(wmInfo.info.win.window, DXGI_MWA_NO_ALT_ENTER);
|
||||
}
|
||||
break;
|
||||
case App::Settings::Platform::uwp:
|
||||
{
|
||||
if (FAILED(hr = pFactory->CreateSwapChainForCoreWindow(_pCommandQueue.Get(), wmInfo.info.winrt.window, &_swapChainDesc, nullptr, &pSwapChain1)))
|
||||
throw VERUS_RUNTIME_ERROR << "CreateSwapChainForCoreWindow(), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "CreateSwapChainForCoreWindow(); hr=" << VERUS_HR(hr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (FAILED(hr = pSwapChain1.As(&_pSwapChain)))
|
||||
throw VERUS_RUNTIME_ERROR << "QueryInterface(), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "QueryInterface(); hr=" << VERUS_HR(hr);
|
||||
|
||||
_pSwapChain->SetMaximumFrameLatency(3);
|
||||
_hFrameLatencyWaitableObject = _pSwapChain->GetFrameLatencyWaitableObject();
|
||||
|
@ -261,7 +261,7 @@ void RendererD3D12::InitD3D()
|
|||
if (!_hFence)
|
||||
{
|
||||
hr = HRESULT_FROM_WIN32(GetLastError());
|
||||
throw VERUS_RUNTIME_ERROR << "CreateEvent(), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "CreateEvent(); hr=" << VERUS_HR(hr);
|
||||
}
|
||||
_fenceValues[_ringBufferIndex]++;
|
||||
|
||||
|
@ -275,7 +275,7 @@ void RendererD3D12::WaitForFrameLatencyWaitableObject()
|
|||
{
|
||||
const DWORD ret = WaitForSingleObjectEx(_hFrameLatencyWaitableObject, 1000, FALSE);
|
||||
if (WAIT_OBJECT_0 != ret)
|
||||
throw VERUS_RUNTIME_ERROR << "WaitForFrameLatencyWaitableObject(), ret=" << VERUS_HR(ret);
|
||||
throw VERUS_RUNTIME_ERROR << "WaitForFrameLatencyWaitableObject(); ret=" << VERUS_HR(ret);
|
||||
}
|
||||
|
||||
ComPtr<ID3D12CommandQueue> RendererD3D12::CreateCommandQueue(D3D12_COMMAND_LIST_TYPE type)
|
||||
|
@ -287,7 +287,7 @@ ComPtr<ID3D12CommandQueue> RendererD3D12::CreateCommandQueue(D3D12_COMMAND_LIST_
|
|||
desc.Priority = D3D12_COMMAND_QUEUE_PRIORITY_NORMAL;
|
||||
desc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE;
|
||||
if (FAILED(hr = _pDevice->CreateCommandQueue(&desc, IID_PPV_ARGS(&pCommandQueue))))
|
||||
throw VERUS_RUNTIME_ERROR << "CreateCommandQueue(), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "CreateCommandQueue(); hr=" << VERUS_HR(hr);
|
||||
return pCommandQueue;
|
||||
}
|
||||
|
||||
|
@ -296,7 +296,7 @@ ComPtr<ID3D12CommandAllocator> RendererD3D12::CreateCommandAllocator(D3D12_COMMA
|
|||
HRESULT hr = 0;
|
||||
ComPtr<ID3D12CommandAllocator> pCommandAllocator;
|
||||
if (FAILED(hr = _pDevice->CreateCommandAllocator(type, IID_PPV_ARGS(&pCommandAllocator))))
|
||||
throw VERUS_RUNTIME_ERROR << "CreateCommandAllocator(), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "CreateCommandAllocator(); hr=" << VERUS_HR(hr);
|
||||
return pCommandAllocator;
|
||||
}
|
||||
|
||||
|
@ -305,9 +305,9 @@ ComPtr<ID3D12GraphicsCommandList3> RendererD3D12::CreateCommandList(D3D12_COMMAN
|
|||
HRESULT hr = 0;
|
||||
ComPtr<ID3D12GraphicsCommandList3> pGraphicsCommandList;
|
||||
if (FAILED(hr = _pDevice->CreateCommandList(0, type, pCommandAllocator.Get(), nullptr, IID_PPV_ARGS(&pGraphicsCommandList))))
|
||||
throw VERUS_RUNTIME_ERROR << "CreateCommandList(), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "CreateCommandList(); hr=" << VERUS_HR(hr);
|
||||
if (FAILED(hr = pGraphicsCommandList->Close()))
|
||||
throw VERUS_RUNTIME_ERROR << "Close(), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "Close(); hr=" << VERUS_HR(hr);
|
||||
return pGraphicsCommandList;
|
||||
}
|
||||
|
||||
|
@ -316,7 +316,7 @@ ComPtr<ID3D12Fence> RendererD3D12::CreateFence()
|
|||
HRESULT hr = 0;
|
||||
ComPtr<ID3D12Fence> pFence;
|
||||
if (FAILED(hr = _pDevice->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&pFence))))
|
||||
throw VERUS_RUNTIME_ERROR << "CreateFence(), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "CreateFence(); hr=" << VERUS_HR(hr);
|
||||
return pFence;
|
||||
}
|
||||
|
||||
|
@ -325,7 +325,7 @@ UINT64 RendererD3D12::QueueSignal()
|
|||
HRESULT hr = 0;
|
||||
const UINT64 value = _fenceValues[_ringBufferIndex];
|
||||
if (FAILED(hr = _pCommandQueue->Signal(_pFence.Get(), value)))
|
||||
throw VERUS_RUNTIME_ERROR << "Signal(), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "Signal(); hr=" << VERUS_HR(hr);
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@ -335,7 +335,7 @@ void RendererD3D12::WaitForFenceValue(UINT64 value)
|
|||
if (_pFence->GetCompletedValue() < value)
|
||||
{
|
||||
if (FAILED(hr = _pFence->SetEventOnCompletion(value, _hFence)))
|
||||
throw VERUS_RUNTIME_ERROR << "SetEventOnCompletion(), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "SetEventOnCompletion(); hr=" << VERUS_HR(hr);
|
||||
WaitForSingleObjectEx(_hFence, INFINITE, FALSE);
|
||||
}
|
||||
}
|
||||
|
@ -524,7 +524,7 @@ void RendererD3D12::BeginFrame(bool present)
|
|||
|
||||
auto pCommandAllocator = _mapCommandAllocators[_ringBufferIndex][std::this_thread::get_id()];
|
||||
if (FAILED(hr = pCommandAllocator->Reset()))
|
||||
throw VERUS_RUNTIME_ERROR << "Reset(), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "Reset(); hr=" << VERUS_HR(hr);
|
||||
|
||||
auto cb = renderer.GetCommandBuffer();
|
||||
cb->Begin();
|
||||
|
@ -561,7 +561,7 @@ void RendererD3D12::Present()
|
|||
if (!syncInterval && allowTearing && App::DisplayMode::exclusiveFullscreen != settings._displayMode)
|
||||
flags |= DXGI_PRESENT_ALLOW_TEARING;
|
||||
if (FAILED(hr = _pSwapChain->Present(syncInterval, flags)))
|
||||
throw VERUS_RUNTIME_ERROR << "Present(), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "Present(); hr=" << VERUS_HR(hr);
|
||||
}
|
||||
|
||||
void RendererD3D12::Sync(bool present)
|
||||
|
@ -659,7 +659,7 @@ RPHandle RendererD3D12::CreateRenderPass(std::initializer_list<RP::Attachment> i
|
|||
return index;
|
||||
index++;
|
||||
}
|
||||
throw VERUS_RECOVERABLE << "CreateRenderPass(), attachment not found";
|
||||
throw VERUS_RECOVERABLE << "CreateRenderPass(); Attachment not found";
|
||||
};
|
||||
|
||||
renderPass._vSubpasses.reserve(ilS.size());
|
||||
|
|
|
@ -237,7 +237,7 @@ void ShaderD3D12::CreateDescriptorSet(int setNumber, const void* pSrc, int size,
|
|||
nullptr,
|
||||
&dsd._pMaAllocation,
|
||||
IID_PPV_ARGS(&dsd._pConstantBuffer))))
|
||||
throw VERUS_RUNTIME_ERROR << "CreateResource(D3D12_HEAP_TYPE_UPLOAD), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "CreateResource(D3D12_HEAP_TYPE_UPLOAD); hr=" << VERUS_HR(hr);
|
||||
dsd._pConstantBuffer->SetName(_C(Str::Utf8ToWide("Shader.ConstantBuffer (" + _sourceName + ", set=" + std::to_string(setNumber) + ")")));
|
||||
|
||||
const int count = dsd._capacity * BaseRenderer::s_ringBufferSize;
|
||||
|
@ -394,10 +394,10 @@ void ShaderD3D12::CreatePipelineLayout()
|
|||
if (FAILED(hr = D3DX12SerializeVersionedRootSignature(&rootSignatureDesc, featureSupportData.HighestVersion, &pRootSignatureBlob, &pErrorBlob)))
|
||||
{
|
||||
CSZ errors = pErrorBlob ? static_cast<CSZ>(pErrorBlob->GetBufferPointer()) : "";
|
||||
throw VERUS_RUNTIME_ERROR << "D3DX12SerializeVersionedRootSignature(), hr=" << VERUS_HR(hr) << ", errors=" << errors;
|
||||
throw VERUS_RUNTIME_ERROR << "D3DX12SerializeVersionedRootSignature(); hr=" << VERUS_HR(hr) << ", errors=" << errors;
|
||||
}
|
||||
if (FAILED(hr = pRendererD3D12->GetD3DDevice()->CreateRootSignature(0, pRootSignatureBlob->GetBufferPointer(), pRootSignatureBlob->GetBufferSize(), IID_PPV_ARGS(&_pRootSignature))))
|
||||
throw VERUS_RUNTIME_ERROR << "CreateRootSignature(), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "CreateRootSignature(); hr=" << VERUS_HR(hr);
|
||||
_pRootSignature->SetName(_C(Str::Utf8ToWide("RootSignature (" + _sourceName + ")")));
|
||||
}
|
||||
|
||||
|
@ -489,7 +489,7 @@ void ShaderD3D12::BeginBindDescriptors()
|
|||
CD3DX12_RANGE readRange(0, 0);
|
||||
void* pData = nullptr;
|
||||
if (FAILED(hr = dsd._pConstantBuffer->Map(0, &readRange, &pData)))
|
||||
throw VERUS_RUNTIME_ERROR << "Map(), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "Map(); hr=" << VERUS_HR(hr);
|
||||
dsd._pMappedData = static_cast<BYTE*>(pData);
|
||||
dsd._pMappedData += dsd._capacityInBytes * pRendererD3D12->GetRingBufferIndex(); // Adjust address for this frame.
|
||||
if (resetOffset)
|
||||
|
|
|
@ -80,7 +80,7 @@ void TextureD3D12::Init(RcTextureDesc desc)
|
|||
(renderTarget || depthFormat) ? &clearValue : nullptr,
|
||||
&_resource._pMaAllocation,
|
||||
IID_PPV_ARGS(&_resource._pResource))))
|
||||
throw VERUS_RUNTIME_ERROR << "CreateResource(D3D12_HEAP_TYPE_DEFAULT), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "CreateResource(D3D12_HEAP_TYPE_DEFAULT); hr=" << VERUS_HR(hr);
|
||||
_resource._pResource->SetName(_C(Str::Utf8ToWide(_name)));
|
||||
|
||||
if (_desc._flags & TextureDesc::Flags::generateMips)
|
||||
|
@ -108,7 +108,7 @@ void TextureD3D12::Init(RcTextureDesc desc)
|
|||
nullptr,
|
||||
&_uaResource._pMaAllocation,
|
||||
IID_PPV_ARGS(&_uaResource._pResource))))
|
||||
throw VERUS_RUNTIME_ERROR << "CreateResource(D3D12_HEAP_TYPE_DEFAULT), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "CreateResource(D3D12_HEAP_TYPE_DEFAULT); hr=" << VERUS_HR(hr);
|
||||
_uaResource._pResource->SetName(_C(Str::Utf8ToWide(_name + " (UAV)")));
|
||||
|
||||
_dhUAV.Create(pRendererD3D12->GetD3DDevice(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, uavMipLevels);
|
||||
|
@ -142,7 +142,7 @@ void TextureD3D12::Init(RcTextureDesc desc)
|
|||
nullptr,
|
||||
&x._pMaAllocation,
|
||||
IID_PPV_ARGS(&x._pResource))))
|
||||
throw VERUS_RUNTIME_ERROR << "CreateResource(D3D12_HEAP_TYPE_READBACK), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "CreateResource(D3D12_HEAP_TYPE_READBACK); hr=" << VERUS_HR(hr);
|
||||
x._pResource->SetName(_C(Str::Utf8ToWide(_name + " (Readback)")));
|
||||
}
|
||||
}
|
||||
|
@ -280,7 +280,7 @@ void TextureD3D12::UpdateSubresource(const void* p, int mipLevel, int arrayLayer
|
|||
nullptr,
|
||||
&sb._pMaAllocation,
|
||||
IID_PPV_ARGS(&sb._pResource))))
|
||||
throw VERUS_RUNTIME_ERROR << "CreateResource(D3D12_HEAP_TYPE_UPLOAD), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "CreateResource(D3D12_HEAP_TYPE_UPLOAD); hr=" << VERUS_HR(hr);
|
||||
sb._pResource->SetName(_C(Str::Utf8ToWide(_name + " (Staging)")));
|
||||
}
|
||||
|
||||
|
@ -353,7 +353,7 @@ bool TextureD3D12::ReadbackSubresource(void* p, bool recordCopyCommand, PBaseCom
|
|||
CD3DX12_RANGE readRange(0, 0);
|
||||
void* pData = nullptr;
|
||||
if (FAILED(hr = rb._pResource->Map(0, &readRange, &pData)))
|
||||
throw VERUS_RUNTIME_ERROR << "Map(), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "Map(); hr=" << VERUS_HR(hr);
|
||||
BYTE* pDst = static_cast<BYTE*>(p);
|
||||
BYTE* pSrc = static_cast<BYTE*>(pData);
|
||||
VERUS_FOR(i, h)
|
||||
|
@ -385,7 +385,7 @@ void TextureD3D12::GenerateMips(PBaseCommandBuffer pCB)
|
|||
|
||||
// Transition state for sampling in compute shader:
|
||||
if (_mainLayout != ImageLayout::xsReadOnly)
|
||||
pCB->PipelineImageMemoryBarrier(tex, _mainLayout, ImageLayout::xsReadOnly, Range<int>(0, maxMipLevel));
|
||||
pCB->PipelineImageMemoryBarrier(tex, _mainLayout, ImageLayout::xsReadOnly, Range(0, _desc._mipLevels));
|
||||
|
||||
pCB->BindPipeline(renderer.GetPipelineGenerateMips(!!(_desc._flags & TextureDesc::Flags::exposureMips)));
|
||||
|
||||
|
@ -394,8 +394,8 @@ void TextureD3D12::GenerateMips(PBaseCommandBuffer pCB)
|
|||
int dispatchIndex = 0;
|
||||
for (int srcMip = 0; srcMip < maxMipLevel;)
|
||||
{
|
||||
const int srcWidth = _desc._width >> srcMip;
|
||||
const int srcHeight = _desc._height >> srcMip;
|
||||
const int srcWidth = Math::Max(1, _desc._width >> srcMip);
|
||||
const int srcHeight = Math::Max(1, _desc._height >> srcMip);
|
||||
const int dstWidth = Math::Max(1, srcWidth >> 1);
|
||||
const int dstHeight = Math::Max(1, srcHeight >> 1);
|
||||
|
||||
|
@ -441,7 +441,7 @@ void TextureD3D12::GenerateMips(PBaseCommandBuffer pCB)
|
|||
}
|
||||
pCmdList->ResourceBarrier(barrierCount, barriers);
|
||||
|
||||
pCB->PipelineImageMemoryBarrier(tex, ImageLayout::xsReadOnly, ImageLayout::transferDst, Range<int>(srcMip + 1, srcMip + dispatchMipCount));
|
||||
pCB->PipelineImageMemoryBarrier(tex, ImageLayout::xsReadOnly, ImageLayout::transferDst, Range(0, dispatchMipCount).OffsetBy(srcMip + 1));
|
||||
}
|
||||
VERUS_FOR(mip, dispatchMipCount)
|
||||
{
|
||||
|
@ -467,7 +467,7 @@ void TextureD3D12::GenerateMips(PBaseCommandBuffer pCB)
|
|||
}
|
||||
pCmdList->ResourceBarrier(barrierCount, barriers);
|
||||
|
||||
pCB->PipelineImageMemoryBarrier(tex, ImageLayout::transferDst, ImageLayout::xsReadOnly, Range<int>(srcMip + 1, srcMip + dispatchMipCount));
|
||||
pCB->PipelineImageMemoryBarrier(tex, ImageLayout::transferDst, ImageLayout::xsReadOnly, Range(0, dispatchMipCount).OffsetBy(srcMip + 1));
|
||||
}
|
||||
|
||||
srcMip += dispatchMipCount;
|
||||
|
@ -477,7 +477,7 @@ void TextureD3D12::GenerateMips(PBaseCommandBuffer pCB)
|
|||
|
||||
// Revert to main state:
|
||||
if (_mainLayout != ImageLayout::xsReadOnly)
|
||||
pCB->PipelineImageMemoryBarrier(tex, ImageLayout::xsReadOnly, _mainLayout, Range<int>(0, maxMipLevel));
|
||||
pCB->PipelineImageMemoryBarrier(tex, ImageLayout::xsReadOnly, _mainLayout, Range(0, _desc._mipLevels));
|
||||
|
||||
Schedule(0);
|
||||
}
|
||||
|
|
|
@ -63,14 +63,14 @@ void CommandBufferVulkan::Begin()
|
|||
if (_oneTimeSubmit)
|
||||
vkcbbi.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
|
||||
if (VK_SUCCESS != (res = vkBeginCommandBuffer(GetVkCommandBuffer(), &vkcbbi)))
|
||||
throw VERUS_RUNTIME_ERROR << "vkBeginCommandBuffer(), res=" << res;
|
||||
throw VERUS_RUNTIME_ERROR << "vkBeginCommandBuffer(); res=" << res;
|
||||
}
|
||||
|
||||
void CommandBufferVulkan::End()
|
||||
{
|
||||
VkResult res = VK_SUCCESS;
|
||||
if (VK_SUCCESS != (res = vkEndCommandBuffer(GetVkCommandBuffer())))
|
||||
throw VERUS_RUNTIME_ERROR << "vkEndCommandBuffer(), res=" << res;
|
||||
throw VERUS_RUNTIME_ERROR << "vkEndCommandBuffer(); res=" << res;
|
||||
}
|
||||
|
||||
void CommandBufferVulkan::BeginRenderPass(RPHandle renderPassHandle, FBHandle framebufferHandle, std::initializer_list<Vector4> ilClearValues, bool setViewportAndScissor)
|
||||
|
@ -225,14 +225,14 @@ void CommandBufferVulkan::PushConstants(ShaderPtr shader, int offset, int size,
|
|||
vkCmdPushConstants(GetVkCommandBuffer(), shaderVulkan.GetVkPipelineLayout(), vkssf, offset << 2, size << 2, p);
|
||||
}
|
||||
|
||||
void CommandBufferVulkan::PipelineImageMemoryBarrier(TexturePtr tex, ImageLayout oldLayout, ImageLayout newLayout, Range<int> mipLevels, int arrayLayer)
|
||||
void CommandBufferVulkan::PipelineImageMemoryBarrier(TexturePtr tex, ImageLayout oldLayout, ImageLayout newLayout, Range mipLevels, int arrayLayer)
|
||||
{
|
||||
auto& texVulkan = static_cast<RTextureVulkan>(*tex);
|
||||
VkPipelineStageFlags srcStageMask = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT; // Waiting for this stage to finish (TOP_OF_PIPE means wait for nothing).
|
||||
VkPipelineStageFlags dstStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT; // Which stage is waiting to start (BOTTOM_OF_PIPE means nothing is waiting).
|
||||
const VkPipelineStageFlags dstStageMaskXS = VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT;
|
||||
VkImageMemoryBarrier vkimb[16];
|
||||
VERUS_RT_ASSERT(mipLevels.GetLength() < VERUS_COUNT_OF(vkimb));
|
||||
VERUS_RT_ASSERT(mipLevels.GetCount() <= VERUS_COUNT_OF(vkimb));
|
||||
int index = 0;
|
||||
for (int mip : mipLevels)
|
||||
{
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace verus
|
|||
virtual bool BindDescriptors(ShaderPtr shader, int setNumber, CSHandle complexSetHandle) override;
|
||||
virtual void PushConstants(ShaderPtr shader, int offset, int size, const void* p, ShaderStageFlags stageFlags) override;
|
||||
|
||||
virtual void PipelineImageMemoryBarrier(TexturePtr tex, ImageLayout oldLayout, ImageLayout newLayout, Range<int> mipLevels, int arrayLayer) override;
|
||||
virtual void PipelineImageMemoryBarrier(TexturePtr tex, ImageLayout oldLayout, ImageLayout newLayout, Range mipLevels, int arrayLayer) override;
|
||||
|
||||
virtual void Draw(int vertexCount, int instanceCount, int firstVertex, int firstInstance) override;
|
||||
virtual void DrawIndexed(int indexCount, int instanceCount, int firstIndex, int vertexOffset, int firstInstance) override;
|
||||
|
|
|
@ -123,7 +123,7 @@ void GeometryVulkan::UpdateVertexBuffer(const void* p, int binding, PBaseCommand
|
|||
size = size ? size * elementSize : vb._bufferSize;
|
||||
void* pData = nullptr;
|
||||
if (VK_SUCCESS != (res = vmaMapMemory(pRendererVulkan->GetVmaAllocator(), vb._vmaAllocation, &pData)))
|
||||
throw VERUS_RECOVERABLE << "vmaMapMemory(), res=" << res;
|
||||
throw VERUS_RECOVERABLE << "vmaMapMemory(); res=" << res;
|
||||
BYTE* pMappedData = static_cast<BYTE*>(pData) + pRendererVulkan->GetRingBufferIndex() * vb._bufferSize;
|
||||
memcpy(pMappedData + offset * elementSize, p, size);
|
||||
vmaUnmapMemory(pRendererVulkan->GetVmaAllocator(), vb._vmaAllocation);
|
||||
|
@ -144,7 +144,7 @@ void GeometryVulkan::UpdateVertexBuffer(const void* p, int binding, PBaseCommand
|
|||
|
||||
void* pData = nullptr;
|
||||
if (VK_SUCCESS != (res = vmaMapMemory(pRendererVulkan->GetVmaAllocator(), svb._vmaAllocation, &pData)))
|
||||
throw VERUS_RECOVERABLE << "vmaMapMemory(), res=" << res;
|
||||
throw VERUS_RECOVERABLE << "vmaMapMemory(); res=" << res;
|
||||
memcpy(pData, p, vb._bufferSize);
|
||||
vmaUnmapMemory(pRendererVulkan->GetVmaAllocator(), svb._vmaAllocation);
|
||||
|
||||
|
@ -184,7 +184,7 @@ void GeometryVulkan::UpdateIndexBuffer(const void* p, PBaseCommandBuffer pCB, IN
|
|||
size = size ? size * elementSize : _indexBuffer._bufferSize;
|
||||
void* pData = nullptr;
|
||||
if (VK_SUCCESS != (res = vmaMapMemory(pRendererVulkan->GetVmaAllocator(), _indexBuffer._vmaAllocation, &pData)))
|
||||
throw VERUS_RECOVERABLE << "vmaMapMemory(), res=" << res;
|
||||
throw VERUS_RECOVERABLE << "vmaMapMemory(); res=" << res;
|
||||
BYTE* pMappedData = static_cast<BYTE*>(pData) + pRendererVulkan->GetRingBufferIndex() * _indexBuffer._bufferSize;
|
||||
memcpy(pMappedData + offset * elementSize, p, size);
|
||||
vmaUnmapMemory(pRendererVulkan->GetVmaAllocator(), _indexBuffer._vmaAllocation);
|
||||
|
@ -200,7 +200,7 @@ void GeometryVulkan::UpdateIndexBuffer(const void* p, PBaseCommandBuffer pCB, IN
|
|||
|
||||
void* pData = nullptr;
|
||||
if (VK_SUCCESS != (res = vmaMapMemory(pRendererVulkan->GetVmaAllocator(), _stagingIndexBuffer._vmaAllocation, &pData)))
|
||||
throw VERUS_RECOVERABLE << "vmaMapMemory(), res=" << res;
|
||||
throw VERUS_RECOVERABLE << "vmaMapMemory(); res=" << res;
|
||||
memcpy(pData, p, _indexBuffer._bufferSize);
|
||||
vmaUnmapMemory(pRendererVulkan->GetVmaAllocator(), _stagingIndexBuffer._vmaAllocation);
|
||||
|
||||
|
|
|
@ -245,7 +245,7 @@ VkFormat CGI::ToNativeFormat(ViaUsage usage, ViaType type, int components)
|
|||
return shorts[index];
|
||||
}
|
||||
break;
|
||||
default: throw VERUS_RECOVERABLE << "ToNativeFormat(), ViaType=?";
|
||||
default: throw VERUS_RECOVERABLE << "ToNativeFormat(); ViaType=?";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -154,7 +154,7 @@ void PipelineVulkan::Init(RcPipelineDesc desc)
|
|||
vkgpci.subpass = desc._subpass;
|
||||
vkgpci.basePipelineHandle = VK_NULL_HANDLE;
|
||||
if (VK_SUCCESS != (res = vkCreateGraphicsPipelines(pRendererVulkan->GetVkDevice(), VK_NULL_HANDLE, 1, &vkgpci, pRendererVulkan->GetAllocator(), &_pipeline)))
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateGraphicsPipelines(), res=" << res;
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateGraphicsPipelines(); res=" << res;
|
||||
}
|
||||
|
||||
void PipelineVulkan::Done()
|
||||
|
@ -185,7 +185,7 @@ void PipelineVulkan::InitCompute(RcPipelineDesc desc)
|
|||
vkcpci.stage.pName = _C(entryName);
|
||||
vkcpci.layout = shader.GetVkPipelineLayout();
|
||||
if (VK_SUCCESS != (res = vkCreateComputePipelines(pRendererVulkan->GetVkDevice(), VK_NULL_HANDLE, 1, &vkcpci, pRendererVulkan->GetAllocator(), &_pipeline)))
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateComputePipelines(), res=" << res;
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateComputePipelines(); res=" << res;
|
||||
}
|
||||
|
||||
void PipelineVulkan::FillColorBlendAttachmentStates(RcPipelineDesc desc, int attachmentCount, VkPipelineColorBlendAttachmentState vkpcbas[])
|
||||
|
|
|
@ -82,7 +82,7 @@ void RendererVulkan::Init()
|
|||
vmaaci.pAllocationCallbacks = GetAllocator();
|
||||
vmaaci.frameInUseCount = s_ringBufferSize;
|
||||
if (VK_SUCCESS != (res = vmaCreateAllocator(&vmaaci, &_vmaAllocator)))
|
||||
throw VERUS_RUNTIME_ERROR << "vmaCreateAllocator(), res=" << res;
|
||||
throw VERUS_RUNTIME_ERROR << "vmaCreateAllocator(); res=" << res;
|
||||
|
||||
CreateSwapChain();
|
||||
CreateImageViews();
|
||||
|
@ -281,7 +281,7 @@ void RendererVulkan::CreateInstance()
|
|||
vkici.ppEnabledLayerNames = s_requiredValidationLayers;
|
||||
#endif
|
||||
if (VK_SUCCESS != (res = vkCreateInstance(&vkici, GetAllocator(), &_instance)))
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateInstance(), res=" << res;
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateInstance(); res=" << res;
|
||||
}
|
||||
|
||||
void RendererVulkan::FillDebugUtilsMessengerCreateInfo(VkDebugUtilsMessengerCreateInfoEXT& vkdumci)
|
||||
|
@ -307,7 +307,7 @@ void RendererVulkan::CreateDebugUtilsMessenger()
|
|||
VkDebugUtilsMessengerCreateInfoEXT vkdumci = {};
|
||||
FillDebugUtilsMessengerCreateInfo(vkdumci);
|
||||
if (VK_SUCCESS != (res = CreateDebugUtilsMessengerEXT(_instance, &vkdumci, GetAllocator(), &_debugUtilsMessenger)))
|
||||
throw VERUS_RUNTIME_ERROR << "CreateDebugUtilsMessengerEXT(), res=" << res;
|
||||
throw VERUS_RUNTIME_ERROR << "CreateDebugUtilsMessengerEXT(); res=" << res;
|
||||
}
|
||||
|
||||
void RendererVulkan::CreateSurface()
|
||||
|
@ -380,7 +380,7 @@ void RendererVulkan::PickPhysicalDevice()
|
|||
uint32_t physicalDeviceCount = 0;
|
||||
vkEnumeratePhysicalDevices(_instance, &physicalDeviceCount, nullptr);
|
||||
if (!physicalDeviceCount)
|
||||
throw VERUS_RUNTIME_ERROR << "vkEnumeratePhysicalDevices(), physicalDeviceCount=0";
|
||||
throw VERUS_RUNTIME_ERROR << "vkEnumeratePhysicalDevices(); physicalDeviceCount=0";
|
||||
Vector<VkPhysicalDevice> vPhysicalDevices(physicalDeviceCount);
|
||||
vkEnumeratePhysicalDevices(_instance, &physicalDeviceCount, vPhysicalDevices.data());
|
||||
for (const auto& physicalDevice : vPhysicalDevices)
|
||||
|
@ -451,7 +451,7 @@ void RendererVulkan::CreateDevice()
|
|||
vkdci.ppEnabledExtensionNames = s_requiredDeviceExtensions;
|
||||
vkdci.pEnabledFeatures = &physicalDeviceFeatures;
|
||||
if (VK_SUCCESS != (res = vkCreateDevice(_physicalDevice, &vkdci, GetAllocator(), &_device)))
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateDevice(), res=" << res;
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateDevice(); res=" << res;
|
||||
|
||||
vkGetDeviceQueue(_device, _queueFamilyIndices._graphicsFamilyIndex, 0, &_graphicsQueue);
|
||||
vkGetDeviceQueue(_device, _queueFamilyIndices._presentFamilyIndex, 0, &_presentQueue);
|
||||
|
@ -530,7 +530,7 @@ void RendererVulkan::CreateSwapChain(VkSwapchainKHR oldSwapchain)
|
|||
vksci.pQueueFamilyIndices = queueFamilyIndicesArray;
|
||||
}
|
||||
if (VK_SUCCESS != (res = vkCreateSwapchainKHR(_device, &vksci, GetAllocator(), &_swapChain)))
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateSwapchainKHR(), res=" << res;
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateSwapchainKHR(); res=" << res;
|
||||
|
||||
vkGetSwapchainImagesKHR(_device, _swapChain, &_swapChainBufferCount, nullptr);
|
||||
_vSwapChainImages.resize(_swapChainBufferCount);
|
||||
|
@ -558,7 +558,7 @@ void RendererVulkan::CreateImageViews()
|
|||
vkivci.subresourceRange.baseArrayLayer = 0;
|
||||
vkivci.subresourceRange.layerCount = 1;
|
||||
if (VK_SUCCESS != (res = vkCreateImageView(_device, &vkivci, GetAllocator(), &_vSwapChainImageViews[i])))
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateImageView(), res=" << res;
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateImageView(); res=" << res;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -571,7 +571,7 @@ void RendererVulkan::CreateCommandPools()
|
|||
vkcpci.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
|
||||
vkcpci.queueFamilyIndex = _queueFamilyIndices._graphicsFamilyIndex;
|
||||
if (VK_SUCCESS != (res = vkCreateCommandPool(_device, &vkcpci, GetAllocator(), &_commandPools[i])))
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateCommandPool(), res=" << res;
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateCommandPool(); res=" << res;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -586,11 +586,11 @@ void RendererVulkan::CreateSyncObjects()
|
|||
VERUS_U_FOR(i, s_ringBufferSize)
|
||||
{
|
||||
if (VK_SUCCESS != (res = vkCreateSemaphore(_device, &vksci, GetAllocator(), &_acquireNextImageSemaphores[i])))
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateSemaphore(), res=" << res;
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateSemaphore(); res=" << res;
|
||||
if (VK_SUCCESS != (res = vkCreateSemaphore(_device, &vksci, GetAllocator(), &_queueSubmitSemaphores[i])))
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateSemaphore(), res=" << res;
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateSemaphore(); res=" << res;
|
||||
if (VK_SUCCESS != (res = vkCreateFence(_device, &vkfci, GetAllocator(), &_queueSubmitFences[i])))
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateFence(), res=" << res;
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateFence(); res=" << res;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -625,7 +625,7 @@ void RendererVulkan::CreateSamplers()
|
|||
VkResult res = VK_SUCCESS;
|
||||
VkSampler sampler = VK_NULL_HANDLE;
|
||||
if (VK_SUCCESS != (res = vkCreateSampler(_device, &vksci, GetAllocator(), &sampler)))
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateSampler(), res=" << res;
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateSampler(); res=" << res;
|
||||
return sampler;
|
||||
};
|
||||
|
||||
|
@ -719,7 +719,7 @@ VkCommandBuffer RendererVulkan::CreateCommandBuffer(VkCommandPool commandPool)
|
|||
vkcbai.commandBufferCount = 1;
|
||||
VkCommandBuffer commandBuffer = VK_NULL_HANDLE;
|
||||
if (VK_SUCCESS != (res = vkAllocateCommandBuffers(_device, &vkcbai, &commandBuffer)))
|
||||
throw VERUS_RUNTIME_ERROR << "vkAllocateCommandBuffers(), res=" << res;
|
||||
throw VERUS_RUNTIME_ERROR << "vkAllocateCommandBuffers(); res=" << res;
|
||||
return commandBuffer;
|
||||
}
|
||||
|
||||
|
@ -731,7 +731,7 @@ const VkSampler* RendererVulkan::GetImmutableSampler(Sampler s) const
|
|||
void RendererVulkan::ImGuiCheckVkResultFn(VkResult res)
|
||||
{
|
||||
if (VK_SUCCESS != res)
|
||||
throw VERUS_RUNTIME_ERROR << "ImGuiCheckVkResultFn(), res=" << res;
|
||||
throw VERUS_RUNTIME_ERROR << "ImGuiCheckVkResultFn(); res=" << res;
|
||||
}
|
||||
|
||||
void RendererVulkan::ImGuiInit(RPHandle renderPassHandle)
|
||||
|
@ -744,7 +744,7 @@ void RendererVulkan::ImGuiInit(RPHandle renderPassHandle)
|
|||
vkdpci.poolSizeCount = 1;
|
||||
vkdpci.pPoolSizes = &vkdps;
|
||||
if (VK_SUCCESS != (res = vkCreateDescriptorPool(_device, &vkdpci, GetAllocator(), &_descriptorPoolImGui)))
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateDescriptorPool(), res=" << res;
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateDescriptorPool(); res=" << res;
|
||||
|
||||
VERUS_QREF_RENDERER;
|
||||
VERUS_QREF_CONST_SETTINGS;
|
||||
|
@ -818,17 +818,17 @@ void RendererVulkan::BeginFrame(bool present)
|
|||
VkResult res = VK_SUCCESS;
|
||||
|
||||
if (VK_SUCCESS != (res = vkResetFences(_device, 1, &_queueSubmitFences[_ringBufferIndex])))
|
||||
throw VERUS_RUNTIME_ERROR << "vkResetFences(), res=" << res;
|
||||
throw VERUS_RUNTIME_ERROR << "vkResetFences(); res=" << res;
|
||||
if (present)
|
||||
{
|
||||
if (VK_SUCCESS != (res = vkAcquireNextImageKHR(_device, _swapChain, UINT64_MAX, _acquireNextImageSemaphores[_ringBufferIndex], VK_NULL_HANDLE, &_swapChainBufferIndex)))
|
||||
throw VERUS_RUNTIME_ERROR << "vkAcquireNextImageKHR(), res=" << res;
|
||||
throw VERUS_RUNTIME_ERROR << "vkAcquireNextImageKHR(); res=" << res;
|
||||
}
|
||||
|
||||
vmaSetCurrentFrameIndex(_vmaAllocator, static_cast<uint32_t>(renderer.GetFrameCount()));
|
||||
|
||||
if (VK_SUCCESS != (res = vkResetCommandPool(_device, _commandPools[_ringBufferIndex], VK_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT)))
|
||||
throw VERUS_RUNTIME_ERROR << "vkResetCommandPool(), res=" << res;
|
||||
throw VERUS_RUNTIME_ERROR << "vkResetCommandPool(); res=" << res;
|
||||
|
||||
renderer.GetCommandBuffer()->Begin();
|
||||
|
||||
|
@ -869,7 +869,7 @@ void RendererVulkan::EndFrame(bool present)
|
|||
vksi.pSignalSemaphores = &_queueSubmitSemaphore;
|
||||
}
|
||||
if (VK_SUCCESS != (res = vkQueueSubmit(_graphicsQueue, 1, &vksi, _queueSubmitFences[_ringBufferIndex])))
|
||||
throw VERUS_RUNTIME_ERROR << "vkQueueSubmit(), res=" << res;
|
||||
throw VERUS_RUNTIME_ERROR << "vkQueueSubmit(); res=" << res;
|
||||
}
|
||||
|
||||
void RendererVulkan::Present()
|
||||
|
@ -891,7 +891,7 @@ void RendererVulkan::Present()
|
|||
if (VK_SUCCESS != (res = vkQueuePresentKHR(_presentQueue, &vkpi)))
|
||||
{
|
||||
if (res != VK_ERROR_OUT_OF_DATE_KHR)
|
||||
throw VERUS_RUNTIME_ERROR << "vkQueuePresentKHR(), res=" << res;
|
||||
throw VERUS_RUNTIME_ERROR << "vkQueuePresentKHR(); res=" << res;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -902,7 +902,7 @@ void RendererVulkan::Sync(bool present)
|
|||
_ringBufferIndex = (_ringBufferIndex + 1) % s_ringBufferSize;
|
||||
|
||||
if (VK_SUCCESS != (res = vkWaitForFences(_device, 1, &_queueSubmitFences[_ringBufferIndex], VK_TRUE, UINT64_MAX)))
|
||||
throw VERUS_RUNTIME_ERROR << "vkWaitForFences(), res=" << res;
|
||||
throw VERUS_RUNTIME_ERROR << "vkWaitForFences(); res=" << res;
|
||||
}
|
||||
|
||||
void RendererVulkan::WaitIdle()
|
||||
|
@ -974,7 +974,7 @@ RPHandle RendererVulkan::CreateRenderPass(std::initializer_list<RP::Attachment>
|
|||
case RP::Attachment::LoadOp::load: return VK_ATTACHMENT_LOAD_OP_LOAD;
|
||||
case RP::Attachment::LoadOp::clear: return VK_ATTACHMENT_LOAD_OP_CLEAR;
|
||||
case RP::Attachment::LoadOp::dontCare: return VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||
default: throw VERUS_RECOVERABLE << "CreateRenderPass(), LoadOp";
|
||||
default: throw VERUS_RECOVERABLE << "CreateRenderPass(); LoadOp";
|
||||
};
|
||||
};
|
||||
auto ToNativeStoreOp = [](RP::Attachment::StoreOp op)
|
||||
|
@ -983,7 +983,7 @@ RPHandle RendererVulkan::CreateRenderPass(std::initializer_list<RP::Attachment>
|
|||
{
|
||||
case RP::Attachment::StoreOp::store: return VK_ATTACHMENT_STORE_OP_STORE;
|
||||
case RP::Attachment::StoreOp::dontCare: return VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||
default: throw VERUS_RECOVERABLE << "CreateRenderPass(), StoreOp";
|
||||
default: throw VERUS_RECOVERABLE << "CreateRenderPass(); StoreOp";
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1014,7 +1014,7 @@ RPHandle RendererVulkan::CreateRenderPass(std::initializer_list<RP::Attachment>
|
|||
return index;
|
||||
index++;
|
||||
}
|
||||
throw VERUS_RECOVERABLE << "CreateRenderPass(), attachment not found";
|
||||
throw VERUS_RECOVERABLE << "CreateRenderPass(); Attachment not found";
|
||||
};
|
||||
|
||||
struct SubpassMetadata
|
||||
|
@ -1084,7 +1084,7 @@ RPHandle RendererVulkan::CreateRenderPass(std::initializer_list<RP::Attachment>
|
|||
|
||||
// vAttachmentRef is ready, convert indices to actual pointers:
|
||||
if (vAttachmentRef.empty())
|
||||
throw VERUS_RECOVERABLE << "CreateRenderPass(), no attachment references";
|
||||
throw VERUS_RECOVERABLE << "CreateRenderPass(); No attachment references";
|
||||
int index = 0;
|
||||
for (auto& sd : vSubpassDesc)
|
||||
{
|
||||
|
@ -1111,7 +1111,7 @@ RPHandle RendererVulkan::CreateRenderPass(std::initializer_list<RP::Attachment>
|
|||
return index;
|
||||
index++;
|
||||
}
|
||||
throw VERUS_RECOVERABLE << "CreateRenderPass(), subpass not found";
|
||||
throw VERUS_RECOVERABLE << "CreateRenderPass(); Subpass not found";
|
||||
};
|
||||
|
||||
Vector<VkSubpassDependency> vSubpassDependency;
|
||||
|
@ -1160,7 +1160,7 @@ RPHandle RendererVulkan::CreateRenderPass(std::initializer_list<RP::Attachment>
|
|||
vkrpci.dependencyCount = Utils::Cast32(vSubpassDependency.size());
|
||||
vkrpci.pDependencies = vSubpassDependency.data();
|
||||
if (VK_SUCCESS != (res = vkCreateRenderPass(_device, &vkrpci, GetAllocator(), &renderPass)))
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateRenderPass(), res=" << res;
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateRenderPass(); res=" << res;
|
||||
|
||||
const int nextIndex = GetNextRenderPassIndex();
|
||||
if (nextIndex >= _vRenderPasses.size())
|
||||
|
@ -1204,7 +1204,7 @@ FBHandle RendererVulkan::CreateFramebuffer(RPHandle renderPassHandle, std::initi
|
|||
vkfci.height = h;
|
||||
vkfci.layers = 1;
|
||||
if (VK_SUCCESS != (res = vkCreateFramebuffer(_device, &vkfci, GetAllocator(), &framebuffer)))
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateFramebuffer(), res=" << res;
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateFramebuffer(); res=" << res;
|
||||
|
||||
const int nextIndex = GetNextFramebufferIndex();
|
||||
Framebuffer fb;
|
||||
|
@ -1292,7 +1292,7 @@ void RendererVulkan::CreateBuffer(VkDeviceSize size, VkBufferUsageFlags usage, V
|
|||
VmaAllocationCreateInfo vmaaci = {};
|
||||
vmaaci.usage = vmaUsage;
|
||||
if (VK_SUCCESS != (res = vmaCreateBuffer(_vmaAllocator, &vkbci, &vmaaci, &buffer, &vmaAllocation, nullptr)))
|
||||
throw VERUS_RECOVERABLE << "vmaCreateBuffer(), res=" << res;
|
||||
throw VERUS_RECOVERABLE << "vmaCreateBuffer(); res=" << res;
|
||||
}
|
||||
|
||||
void RendererVulkan::CopyBuffer(VkBuffer srcBuffer, VkBuffer dstBuffer, VkDeviceSize size, PBaseCommandBuffer pCB)
|
||||
|
@ -1315,7 +1315,7 @@ void RendererVulkan::CreateImage(const VkImageCreateInfo* pImageCreateInfo, VmaM
|
|||
VmaAllocationCreateInfo vmaaci = {};
|
||||
vmaaci.usage = vmaUsage;
|
||||
if (VK_SUCCESS != (res = vmaCreateImage(_vmaAllocator, pImageCreateInfo, &vmaaci, &image, &vmaAllocation, nullptr)))
|
||||
throw VERUS_RECOVERABLE << "vmaCreateImage(), res=" << res;
|
||||
throw VERUS_RECOVERABLE << "vmaCreateImage(); res=" << res;
|
||||
}
|
||||
|
||||
void RendererVulkan::CopyImage(
|
||||
|
|
|
@ -67,7 +67,7 @@ void ShaderVulkan::Init(CSZ source, CSZ sourceName, CSZ* branches)
|
|||
vksmci.codeSize = size;
|
||||
vksmci.pCode = pCode;
|
||||
if (VK_SUCCESS != (res = vkCreateShaderModule(pRendererVulkan->GetVkDevice(), &vksmci, pRendererVulkan->GetAllocator(), &shaderModule)))
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateShaderModule(), res=" << res;
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateShaderModule(); res=" << res;
|
||||
};
|
||||
|
||||
while (*branches)
|
||||
|
@ -364,7 +364,7 @@ void ShaderVulkan::CreatePipelineLayout()
|
|||
|
||||
VkDescriptorSetLayout descriptorSetLayout = VK_NULL_HANDLE;
|
||||
if (VK_SUCCESS != (res = vkCreateDescriptorSetLayout(pRendererVulkan->GetVkDevice(), &vkdslci, pRendererVulkan->GetAllocator(), &descriptorSetLayout)))
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateDescriptorSetLayout(), res=" << res;
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateDescriptorSetLayout(); res=" << res;
|
||||
|
||||
_vDescriptorSetLayouts.push_back(descriptorSetLayout);
|
||||
}
|
||||
|
@ -394,7 +394,7 @@ void ShaderVulkan::CreatePipelineLayout()
|
|||
_debugInfo = ss.str();
|
||||
|
||||
if (VK_SUCCESS != (res = vkCreatePipelineLayout(pRendererVulkan->GetVkDevice(), &vkplci, pRendererVulkan->GetAllocator(), &_pipelineLayout)))
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreatePipelineLayout(), res=" << res;
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreatePipelineLayout(); res=" << res;
|
||||
|
||||
_vComplexDescriptorSets.reserve(_poolComplexUniformBuffers);
|
||||
|
||||
|
@ -437,7 +437,7 @@ CSHandle ShaderVulkan::BindDescriptorSetTextures(int setNumber, std::initializer
|
|||
vkdsai.pSetLayouts = &_vDescriptorSetLayouts[setNumber];
|
||||
VkDescriptorSet descriptorSet = VK_NULL_HANDLE;
|
||||
if (VK_SUCCESS != (res = vkAllocateDescriptorSets(pRendererVulkan->GetVkDevice(), &vkdsai, &descriptorSet)))
|
||||
throw VERUS_RUNTIME_ERROR << "vkAllocateDescriptorSets(), res=" << res;
|
||||
throw VERUS_RUNTIME_ERROR << "vkAllocateDescriptorSets(); res=" << res;
|
||||
_vComplexDescriptorSets[complexSetHandle] = descriptorSet;
|
||||
|
||||
// Info structures:
|
||||
|
@ -524,7 +524,7 @@ void ShaderVulkan::FreeDescriptorSet(CSHandle& complexSetHandle)
|
|||
if (complexSetHandle.IsSet() && complexSetHandle.Get() < _vComplexDescriptorSets.size() && _vComplexDescriptorSets[complexSetHandle.Get()] != VK_NULL_HANDLE)
|
||||
{
|
||||
if (VK_SUCCESS != (res = vkFreeDescriptorSets(pRendererVulkan->GetVkDevice(), _descriptorPool, 1, &_vComplexDescriptorSets[complexSetHandle.Get()])))
|
||||
throw VERUS_RUNTIME_ERROR << "vkFreeDescriptorSets(), res=" << res;
|
||||
throw VERUS_RUNTIME_ERROR << "vkFreeDescriptorSets(); res=" << res;
|
||||
_vComplexDescriptorSets[complexSetHandle.Get()] = VK_NULL_HANDLE;
|
||||
}
|
||||
complexSetHandle = CSHandle();
|
||||
|
@ -546,7 +546,7 @@ void ShaderVulkan::BeginBindDescriptors()
|
|||
VERUS_RT_ASSERT(!dsd._pMappedData);
|
||||
void* pData = nullptr;
|
||||
if (VK_SUCCESS != (res = vmaMapMemory(pRendererVulkan->GetVmaAllocator(), dsd._vmaAllocation, &pData)))
|
||||
throw VERUS_RECOVERABLE << "vmaMapMemory(), res=" << res;
|
||||
throw VERUS_RECOVERABLE << "vmaMapMemory(); res=" << res;
|
||||
dsd._pMappedData = static_cast<BYTE*>(pData);
|
||||
dsd._pMappedData += dsd._capacityInBytes * pRendererVulkan->GetRingBufferIndex(); // Adjust address for this frame.
|
||||
if (resetOffset)
|
||||
|
@ -598,7 +598,7 @@ void ShaderVulkan::CreateDescriptorPool()
|
|||
}
|
||||
vkdpci.pPoolSizes = vkdps;
|
||||
if (VK_SUCCESS != (res = vkCreateDescriptorPool(pRendererVulkan->GetVkDevice(), &vkdpci, pRendererVulkan->GetAllocator(), &_descriptorPool)))
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateDescriptorPool(), res=" << res;
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateDescriptorPool(); res=" << res;
|
||||
}
|
||||
|
||||
void ShaderVulkan::CreateDescriptorSets()
|
||||
|
@ -617,7 +617,7 @@ void ShaderVulkan::CreateDescriptorSets()
|
|||
vkdsai.descriptorSetCount = 1;
|
||||
vkdsai.pSetLayouts = &_vDescriptorSetLayouts[index];
|
||||
if (VK_SUCCESS != (res = vkAllocateDescriptorSets(pRendererVulkan->GetVkDevice(), &vkdsai, &dsd._descriptorSet)))
|
||||
throw VERUS_RUNTIME_ERROR << "vkAllocateDescriptorSets(), res=" << res;
|
||||
throw VERUS_RUNTIME_ERROR << "vkAllocateDescriptorSets(); res=" << res;
|
||||
}
|
||||
|
||||
if (dsd._capacity > 0)
|
||||
|
|
|
@ -102,7 +102,7 @@ void TextureVulkan::Init(RcTextureDesc desc)
|
|||
vkivci.subresourceRange.baseArrayLayer = 0;
|
||||
vkivci.subresourceRange.layerCount = 1;
|
||||
if (VK_SUCCESS != (res = vkCreateImageView(pRendererVulkan->GetVkDevice(), &vkivci, pRendererVulkan->GetAllocator(), &_vStorageImageViews[mip])))
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateImageView(), res=" << res;
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateImageView(); res=" << res;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ void TextureVulkan::Init(RcTextureDesc desc)
|
|||
vkivci.subresourceRange.baseArrayLayer = 0;
|
||||
vkivci.subresourceRange.layerCount = vkici.arrayLayers;
|
||||
if (VK_SUCCESS != (res = vkCreateImageView(pRendererVulkan->GetVkDevice(), &vkivci, pRendererVulkan->GetAllocator(), &_imageView)))
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateImageView(), res=" << res;
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateImageView(); res=" << res;
|
||||
if (renderTarget)
|
||||
{
|
||||
vkivci.viewType = VK_IMAGE_VIEW_TYPE_2D;
|
||||
|
@ -148,13 +148,13 @@ void TextureVulkan::Init(RcTextureDesc desc)
|
|||
{
|
||||
vkivci.subresourceRange.baseArrayLayer = ToNativeCubeMapFace(static_cast<CubeMapFace>(i));
|
||||
if (VK_SUCCESS != (res = vkCreateImageView(pRendererVulkan->GetVkDevice(), &vkivci, pRendererVulkan->GetAllocator(), _imageViewForFramebuffer + i)))
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateImageView(LevelZero), res=" << res;
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateImageView(LevelZero); res=" << res;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (VK_SUCCESS != (res = vkCreateImageView(pRendererVulkan->GetVkDevice(), &vkivci, pRendererVulkan->GetAllocator(), _imageViewForFramebuffer)))
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateImageView(LevelZero), res=" << res;
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateImageView(LevelZero); res=" << res;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -239,7 +239,7 @@ void TextureVulkan::UpdateSubresource(const void* p, int mipLevel, int arrayLaye
|
|||
|
||||
void* pData = nullptr;
|
||||
if (VK_SUCCESS != (res = vmaMapMemory(pRendererVulkan->GetVmaAllocator(), sb._vmaAllocation, &pData)))
|
||||
throw VERUS_RECOVERABLE << "vmaMapMemory(), res=" << res;
|
||||
throw VERUS_RECOVERABLE << "vmaMapMemory(); res=" << res;
|
||||
memcpy(pData, p, bufferSize);
|
||||
vmaUnmapMemory(pRendererVulkan->GetVmaAllocator(), sb._vmaAllocation);
|
||||
|
||||
|
@ -286,7 +286,7 @@ bool TextureVulkan::ReadbackSubresource(void* p, bool recordCopyCommand, PBaseCo
|
|||
{
|
||||
void* pData = nullptr;
|
||||
if (VK_SUCCESS != (res = vmaMapMemory(pRendererVulkan->GetVmaAllocator(), rb._vmaAllocation, &pData)))
|
||||
throw VERUS_RECOVERABLE << "vmaMapMemory(), res=" << res;
|
||||
throw VERUS_RECOVERABLE << "vmaMapMemory(); res=" << res;
|
||||
memcpy(p, pData, bufferSize);
|
||||
vmaUnmapMemory(pRendererVulkan->GetVmaAllocator(), rb._vmaAllocation);
|
||||
}
|
||||
|
@ -307,13 +307,12 @@ void TextureVulkan::GenerateMips(PBaseCommandBuffer pCB)
|
|||
auto tex = TexturePtr::From(this);
|
||||
|
||||
const int maxMipLevel = _desc._mipLevels - 1;
|
||||
const int storageMaxMipLevel = _desc._mipLevels - 2; // Largest mip level not included.
|
||||
|
||||
if (!_definedStorage)
|
||||
{
|
||||
_definedStorage = true;
|
||||
std::swap(_image, _storageImage);
|
||||
pCB->PipelineImageMemoryBarrier(tex, ImageLayout::undefined, ImageLayout::general, Range<int>(0, storageMaxMipLevel));
|
||||
pCB->PipelineImageMemoryBarrier(tex, ImageLayout::undefined, ImageLayout::general, Range(0, maxMipLevel));
|
||||
std::swap(_image, _storageImage);
|
||||
}
|
||||
|
||||
|
@ -323,7 +322,7 @@ void TextureVulkan::GenerateMips(PBaseCommandBuffer pCB)
|
|||
if (firstMipLayout != ImageLayout::xsReadOnly)
|
||||
pCB->PipelineImageMemoryBarrier(tex, firstMipLayout, ImageLayout::xsReadOnly, 0);
|
||||
if (otherMipsLayout != ImageLayout::xsReadOnly)
|
||||
pCB->PipelineImageMemoryBarrier(tex, otherMipsLayout, ImageLayout::xsReadOnly, Range<int>(1, maxMipLevel));
|
||||
pCB->PipelineImageMemoryBarrier(tex, otherMipsLayout, ImageLayout::xsReadOnly, Range(1, _desc._mipLevels));
|
||||
VERUS_FOR(mip, _desc._mipLevels)
|
||||
MarkSubresourceDefined(mip, 0);
|
||||
|
||||
|
@ -334,8 +333,8 @@ void TextureVulkan::GenerateMips(PBaseCommandBuffer pCB)
|
|||
int dispatchIndex = 0;
|
||||
for (int srcMip = 0; srcMip < maxMipLevel;)
|
||||
{
|
||||
const int srcWidth = _desc._width >> srcMip;
|
||||
const int srcHeight = _desc._height >> srcMip;
|
||||
const int srcWidth = Math::Max(1, _desc._width >> srcMip);
|
||||
const int srcHeight = Math::Max(1, _desc._height >> srcMip);
|
||||
const int dstWidth = Math::Max(1, srcWidth >> 1);
|
||||
const int dstHeight = Math::Max(1, srcHeight >> 1);
|
||||
|
||||
|
@ -369,10 +368,10 @@ void TextureVulkan::GenerateMips(PBaseCommandBuffer pCB)
|
|||
// Change layout for upcoming CopyImage():
|
||||
{
|
||||
std::swap(_image, _storageImage);
|
||||
pCB->PipelineImageMemoryBarrier(tex, ImageLayout::general, ImageLayout::transferSrc, Range<int>(srcMip, srcMip + dispatchMipCount - 1));
|
||||
pCB->PipelineImageMemoryBarrier(tex, ImageLayout::general, ImageLayout::transferSrc, Range(0, dispatchMipCount).OffsetBy(srcMip));
|
||||
std::swap(_image, _storageImage);
|
||||
|
||||
pCB->PipelineImageMemoryBarrier(tex, ImageLayout::xsReadOnly, ImageLayout::transferDst, Range<int>(srcMip + 1, srcMip + dispatchMipCount));
|
||||
pCB->PipelineImageMemoryBarrier(tex, ImageLayout::xsReadOnly, ImageLayout::transferDst, Range(0, dispatchMipCount).OffsetBy(srcMip + 1));
|
||||
}
|
||||
VERUS_FOR(mip, dispatchMipCount)
|
||||
{
|
||||
|
@ -388,10 +387,10 @@ void TextureVulkan::GenerateMips(PBaseCommandBuffer pCB)
|
|||
// Change layout for next Dispatch():
|
||||
{
|
||||
std::swap(_image, _storageImage);
|
||||
pCB->PipelineImageMemoryBarrier(tex, ImageLayout::transferSrc, ImageLayout::general, Range<int>(srcMip, srcMip + dispatchMipCount - 1));
|
||||
pCB->PipelineImageMemoryBarrier(tex, ImageLayout::transferSrc, ImageLayout::general, Range(0, dispatchMipCount).OffsetBy(srcMip));
|
||||
std::swap(_image, _storageImage);
|
||||
|
||||
pCB->PipelineImageMemoryBarrier(tex, ImageLayout::transferDst, ImageLayout::xsReadOnly, Range<int>(srcMip + 1, srcMip + dispatchMipCount));
|
||||
pCB->PipelineImageMemoryBarrier(tex, ImageLayout::transferDst, ImageLayout::xsReadOnly, Range(0, dispatchMipCount).OffsetBy(srcMip + 1));
|
||||
}
|
||||
|
||||
srcMip += dispatchMipCount;
|
||||
|
@ -402,7 +401,7 @@ void TextureVulkan::GenerateMips(PBaseCommandBuffer pCB)
|
|||
// Revert to main layout:
|
||||
const ImageLayout finalMipLayout = GetSubresourceMainLayout(0, 0);
|
||||
if (finalMipLayout != ImageLayout::xsReadOnly)
|
||||
pCB->PipelineImageMemoryBarrier(tex, ImageLayout::xsReadOnly, finalMipLayout, Range<int>(0, maxMipLevel));
|
||||
pCB->PipelineImageMemoryBarrier(tex, ImageLayout::xsReadOnly, finalMipLayout, Range(0, _desc._mipLevels));
|
||||
|
||||
Schedule(0);
|
||||
}
|
||||
|
@ -517,7 +516,7 @@ void TextureVulkan::CreateSampler()
|
|||
vksci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE;
|
||||
|
||||
if (VK_SUCCESS != (res = vkCreateSampler(pRendererVulkan->GetVkDevice(), &vksci, pRendererVulkan->GetAllocator(), &_sampler)))
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateSampler(), res=" << res;
|
||||
throw VERUS_RUNTIME_ERROR << "vkCreateSampler(); res=" << res;
|
||||
|
||||
_desc._pSamplerDesc = nullptr;
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
<ImportGroup Label="PropertySheets" />
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<IncludePath>C:\Compressonator_4.2.5185\include;C:\Home\Projects\Verus\verus\Verus\src;C:\Home\Middleware\AMD Tootle 2.3\include;C:\Home\Middleware\bullet3-2.89\src;C:\Home\Middleware\bullet3-2.89\Extras;C:\Home\Middleware\libogg-1.3.4\include;C:\Home\Middleware\libvorbis-1.3.7\include;C:\Home\Middleware\openal-soft-1.21.1-bin\include;C:\Home\Middleware\SDL2-2.0.16\include;C:\VulkanSDK\1.2.189.0\Include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>C:\Compressonator_4.2.5185\lib\VS2017\x64;C:\Home\Middleware\bullet3-2.89\bin;C:\Home\Middleware\AMD Tootle 2.3\lib;C:\Home\Middleware\libogg-1.3.4\lib;C:\Home\Middleware\libvorbis-1.3.7\lib2;C:\Home\Middleware\openal-soft-1.21.1-bin\libs\Win64;C:\Home\Middleware\SDL2-2.0.16\lib\x64;C:\VulkanSDK\1.2.189.0\Lib;$(LibraryPath)</LibraryPath>
|
||||
<IncludePath>C:\Compressonator_4.2.5185\include;C:\Home\Projects\Verus\verus\Verus\src;C:\Home\Middleware\AMD Tootle 2.3\include;C:\Home\Middleware\bullet3-2.89\src;C:\Home\Middleware\bullet3-2.89\Extras;C:\Home\Middleware\libogg-1.3.4\include;C:\Home\Middleware\libvorbis-1.3.7\include;C:\Home\Middleware\openal-soft-1.21.1-bin\include;C:\Home\Middleware\SDL2-2.0.16\include;C:\VulkanSDK\1.2.189.2\Include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>C:\Compressonator_4.2.5185\lib\VS2017\x64;C:\Home\Middleware\bullet3-2.89\bin;C:\Home\Middleware\AMD Tootle 2.3\lib;C:\Home\Middleware\libogg-1.3.4\lib;C:\Home\Middleware\libvorbis-1.3.7\lib2;C:\Home\Middleware\openal-soft-1.21.1-bin\libs\Win64;C:\Home\Middleware\SDL2-2.0.16\lib\x64;C:\VulkanSDK\1.2.189.2\Lib;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup />
|
||||
<ItemGroup />
|
||||
|
|
|
@ -143,13 +143,17 @@
|
|||
<ClInclude Include="src\Extra\ConvertGLTF.h" />
|
||||
<ClInclude Include="src\Extra\Extra.h" />
|
||||
<ClInclude Include="src\Extra\ConvertX.h" />
|
||||
<ClInclude Include="src\Game\ActiveMechanics.h" />
|
||||
<ClInclude Include="src\Game\BaseGame.h" />
|
||||
<ClInclude Include="src\Game\BaseCharacter.h" />
|
||||
<ClInclude Include="src\Game\ChainAward.h" />
|
||||
<ClInclude Include="src\Game\Cutscene.h" />
|
||||
<ClInclude Include="src\Game\Driving.h" />
|
||||
<ClInclude Include="src\Game\Mechanics.h" />
|
||||
<ClInclude Include="src\Game\ECS\Component.h" />
|
||||
<ClInclude Include="src\Game\ECS\Entity.h" />
|
||||
<ClInclude Include="src\Game\ECS\Lot.h" />
|
||||
<ClInclude Include="src\Game\ECS\LotManager.h" />
|
||||
<ClInclude Include="src\Game\Mechanics\ActiveMechanics.h" />
|
||||
<ClInclude Include="src\Game\Mechanics\Cutscene.h" />
|
||||
<ClInclude Include="src\Game\Mechanics\Driving.h" />
|
||||
<ClInclude Include="src\Game\Mechanics\Mechanics.h" />
|
||||
<ClInclude Include="src\Game\QuestSystem.h" />
|
||||
<ClInclude Include="src\Game\Spirit.h" />
|
||||
<ClInclude Include="src\Game\Game.h" />
|
||||
|
@ -166,6 +170,7 @@
|
|||
<ClInclude Include="src\Global\DifferenceVector.h" />
|
||||
<ClInclude Include="src\Global\EngineInit.h" />
|
||||
<ClInclude Include="src\Global\GlobalVarsClipboard.h" />
|
||||
<ClInclude Include="src\Global\Interval.h" />
|
||||
<ClInclude Include="src\Global\Linear.h" />
|
||||
<ClInclude Include="src\Global\LocalPtr.h" />
|
||||
<ClInclude Include="src\Global\Lockable.h" />
|
||||
|
@ -198,7 +203,7 @@
|
|||
<ClInclude Include="src\GUI\ViewManager.h" />
|
||||
<ClInclude Include="src\GUI\Widget.h" />
|
||||
<ClInclude Include="src\Input\Input.h" />
|
||||
<ClInclude Include="src\Input\KeyMapper.h" />
|
||||
<ClInclude Include="src\Input\InputManager.h" />
|
||||
<ClInclude Include="src\Input\DragController.h" />
|
||||
<ClInclude Include="src\IO\Async.h" />
|
||||
<ClInclude Include="src\IO\DDSHeader.h" />
|
||||
|
@ -357,13 +362,17 @@
|
|||
<ClCompile Include="src\Extra\ConvertGLTF.cpp" />
|
||||
<ClCompile Include="src\Extra\Extra.cpp" />
|
||||
<ClCompile Include="src\Extra\ConvertX.cpp" />
|
||||
<ClCompile Include="src\Game\ActiveMechanics.cpp" />
|
||||
<ClCompile Include="src\Game\BaseGame.cpp" />
|
||||
<ClCompile Include="src\Game\BaseCharacter.cpp" />
|
||||
<ClCompile Include="src\Game\ChainAward.cpp" />
|
||||
<ClCompile Include="src\Game\Cutscene.cpp" />
|
||||
<ClCompile Include="src\Game\Driving.cpp" />
|
||||
<ClCompile Include="src\Game\Mechanics.cpp" />
|
||||
<ClCompile Include="src\Game\ECS\Component.cpp" />
|
||||
<ClCompile Include="src\Game\ECS\Entity.cpp" />
|
||||
<ClCompile Include="src\Game\ECS\Lot.cpp" />
|
||||
<ClCompile Include="src\Game\ECS\LotManager.cpp" />
|
||||
<ClCompile Include="src\Game\Mechanics\ActiveMechanics.cpp" />
|
||||
<ClCompile Include="src\Game\Mechanics\Cutscene.cpp" />
|
||||
<ClCompile Include="src\Game\Mechanics\Driving.cpp" />
|
||||
<ClCompile Include="src\Game\Mechanics\Mechanics.cpp" />
|
||||
<ClCompile Include="src\Game\QuestSystem.cpp" />
|
||||
<ClCompile Include="src\Game\Spirit.cpp" />
|
||||
<ClCompile Include="src\Game\State.cpp" />
|
||||
|
@ -374,8 +383,10 @@
|
|||
<ClCompile Include="src\Global\EngineInit.cpp" />
|
||||
<ClCompile Include="src\Global\Global.cpp" />
|
||||
<ClCompile Include="src\Global\GlobalVarsClipboard.cpp" />
|
||||
<ClCompile Include="src\Global\Interval.cpp" />
|
||||
<ClCompile Include="src\Global\Object.cpp" />
|
||||
<ClCompile Include="src\Global\Random.cpp" />
|
||||
<ClCompile Include="src\Global\Range.cpp" />
|
||||
<ClCompile Include="src\Global\Str.cpp" />
|
||||
<ClCompile Include="src\Global\Timer.cpp" />
|
||||
<ClCompile Include="src\Global\Utils.cpp" />
|
||||
|
@ -397,7 +408,7 @@
|
|||
<ClCompile Include="src\GUI\ViewManager.cpp" />
|
||||
<ClCompile Include="src\GUI\Widget.cpp" />
|
||||
<ClCompile Include="src\Input\Input.cpp" />
|
||||
<ClCompile Include="src\Input\KeyMapper.cpp" />
|
||||
<ClCompile Include="src\Input\InputManager.cpp" />
|
||||
<ClCompile Include="src\Input\DragController.cpp" />
|
||||
<ClCompile Include="src\IO\Async.cpp" />
|
||||
<ClCompile Include="src\IO\DDSHeader.cpp" />
|
||||
|
|
|
@ -100,6 +100,12 @@
|
|||
<Filter Include="src\ThirdParty\imgui">
|
||||
<UniqueIdentifier>{e5d1efc7-6850-406e-8abe-7dc0084d2ac7}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="src\Game\ECS">
|
||||
<UniqueIdentifier>{7a1b235f-6f61-41be-87dc-78a3aa2f7ae2}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="src\Game\Mechanics">
|
||||
<UniqueIdentifier>{e81cdb7e-c6de-41ee-bfe5-76bd2aa3a602}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\CGI\BaseGeometry.h">
|
||||
|
@ -372,7 +378,7 @@
|
|||
<ClInclude Include="src\Input\Input.h">
|
||||
<Filter>src\Input</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Input\KeyMapper.h">
|
||||
<ClInclude Include="src\Input\InputManager.h">
|
||||
<Filter>src\Input</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\App\App.h">
|
||||
|
@ -711,15 +717,6 @@
|
|||
<ClInclude Include="src\Scene\CubeMap.h">
|
||||
<Filter>src\Scene</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Game\Cutscene.h">
|
||||
<Filter>src\Game</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Game\Driving.h">
|
||||
<Filter>src\Game</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Game\Mechanics.h">
|
||||
<Filter>src\Game</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Game\QuestSystem.h">
|
||||
<Filter>src\Game</Filter>
|
||||
</ClInclude>
|
||||
|
@ -753,15 +750,39 @@
|
|||
<ClInclude Include="src\App\UndoManager.h">
|
||||
<Filter>src\App</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Game\ActiveMechanics.h">
|
||||
<Filter>src\Game</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\GUI\Bars.h">
|
||||
<Filter>src\GUI</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\ThirdParty\mikktspace.h">
|
||||
<Filter>src\ThirdParty</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Game\ECS\Component.h">
|
||||
<Filter>src\Game\ECS</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Game\ECS\Entity.h">
|
||||
<Filter>src\Game\ECS</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Game\ECS\Lot.h">
|
||||
<Filter>src\Game\ECS</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Game\ECS\LotManager.h">
|
||||
<Filter>src\Game\ECS</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Game\Mechanics\ActiveMechanics.h">
|
||||
<Filter>src\Game\Mechanics</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Game\Mechanics\Cutscene.h">
|
||||
<Filter>src\Game\Mechanics</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Game\Mechanics\Driving.h">
|
||||
<Filter>src\Game\Mechanics</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Game\Mechanics\Mechanics.h">
|
||||
<Filter>src\Game\Mechanics</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Global\Interval.h">
|
||||
<Filter>src\Global</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\CGI\BaseGeometry.cpp">
|
||||
|
@ -938,7 +959,7 @@
|
|||
<ClCompile Include="src\Input\Input.cpp">
|
||||
<Filter>src\Input</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Input\KeyMapper.cpp">
|
||||
<ClCompile Include="src\Input\InputManager.cpp">
|
||||
<Filter>src\Input</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\App\App.cpp">
|
||||
|
@ -1256,15 +1277,6 @@
|
|||
<ClCompile Include="src\Scene\CubeMap.cpp">
|
||||
<Filter>src\Scene</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Game\Cutscene.cpp">
|
||||
<Filter>src\Game</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Game\Driving.cpp">
|
||||
<Filter>src\Game</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Game\Mechanics.cpp">
|
||||
<Filter>src\Game</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Game\QuestSystem.cpp">
|
||||
<Filter>src\Game</Filter>
|
||||
</ClCompile>
|
||||
|
@ -1295,15 +1307,42 @@
|
|||
<ClCompile Include="src\App\UndoManager.cpp">
|
||||
<Filter>src\App</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Game\ActiveMechanics.cpp">
|
||||
<Filter>src\Game</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\GUI\Bars.cpp">
|
||||
<Filter>src\GUI</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\ThirdParty\mikktspace.c">
|
||||
<Filter>src\ThirdParty</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Game\ECS\Component.cpp">
|
||||
<Filter>src\Game\ECS</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Game\ECS\Entity.cpp">
|
||||
<Filter>src\Game\ECS</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Game\ECS\Lot.cpp">
|
||||
<Filter>src\Game\ECS</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Game\ECS\LotManager.cpp">
|
||||
<Filter>src\Game\ECS</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Game\Mechanics\ActiveMechanics.cpp">
|
||||
<Filter>src\Game\Mechanics</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Game\Mechanics\Cutscene.cpp">
|
||||
<Filter>src\Game\Mechanics</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Game\Mechanics\Driving.cpp">
|
||||
<Filter>src\Game\Mechanics</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Game\Mechanics\Mechanics.cpp">
|
||||
<Filter>src\Game\Mechanics</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Global\Interval.cpp">
|
||||
<Filter>src\Global</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Global\Range.cpp">
|
||||
<Filter>src\Global</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="src\Shaders\Lib.hlsl">
|
||||
|
|
|
@ -176,7 +176,7 @@ void Animation::Pause()
|
|||
_playing = false;
|
||||
}
|
||||
|
||||
void Animation::TransitionTo(CSZ name, Range<float> duration, int randTime, PMotion pFromMotion)
|
||||
void Animation::TransitionTo(CSZ name, Interval duration, int randTime, PMotion pFromMotion)
|
||||
{
|
||||
PMotion pMotion = pFromMotion;
|
||||
if (!_currentMotion.empty() || pFromMotion) // Deal with previous motion?
|
||||
|
@ -221,7 +221,7 @@ void Animation::TransitionTo(CSZ name, Range<float> duration, int randTime, PMot
|
|||
_playing = true;
|
||||
}
|
||||
|
||||
bool Animation::TransitionToNew(std::initializer_list<CSZ> names, Range<float> duration, int randTime, PMotion pFromMotion)
|
||||
bool Animation::TransitionToNew(std::initializer_list<CSZ> names, Interval duration, int randTime, PMotion pFromMotion)
|
||||
{
|
||||
for (auto name : names)
|
||||
{
|
||||
|
|
|
@ -94,9 +94,9 @@ namespace verus
|
|||
Str GetCurrentMotionName() const { return _C(_currentMotion); }
|
||||
|
||||
void TransitionTo(CSZ name,
|
||||
Range<float> duration = 0.5f, int randTime = -1, PMotion pFromMotion = nullptr);
|
||||
Interval duration = 0.5f, int randTime = -1, PMotion pFromMotion = nullptr);
|
||||
bool TransitionToNew(std::initializer_list<CSZ> names,
|
||||
Range<float> duration = 0.5f, int randTime = -1, PMotion pFromMotion = nullptr);
|
||||
Interval duration = 0.5f, int randTime = -1, PMotion pFromMotion = nullptr);
|
||||
bool IsInTransition() const { return _transition; }
|
||||
|
||||
void SetEasing(Easing easing) { _easing = easing; }
|
||||
|
|
|
@ -1002,26 +1002,26 @@ void Motion::Deserialize(IO::RStream stream)
|
|||
UINT32 magic = 0;
|
||||
stream >> magic;
|
||||
if ('2NAX' != magic)
|
||||
throw VERUS_RECOVERABLE << "Deserialize(), invalid XAN format";
|
||||
throw VERUS_RECOVERABLE << "Deserialize(); Invalid XAN format";
|
||||
|
||||
UINT16 version = 0;
|
||||
stream >> version;
|
||||
if (s_xanVersion < version)
|
||||
throw VERUS_RECOVERABLE << "Deserialize(), invalid XAN version";
|
||||
throw VERUS_RECOVERABLE << "Deserialize(); Invalid XAN version";
|
||||
|
||||
stream >> _frameCount;
|
||||
stream >> _fps;
|
||||
if (_frameCount < 0 || _frameCount > s_maxFrames)
|
||||
throw VERUS_RECOVERABLE << "Deserialize(), invalid number of frames in XAN";
|
||||
throw VERUS_RECOVERABLE << "Deserialize(); Invalid number of frames in XAN";
|
||||
if (_fps <= 0 || _fps > s_maxFps)
|
||||
throw VERUS_RECOVERABLE << "Deserialize(), invalid FPS in XAN";
|
||||
throw VERUS_RECOVERABLE << "Deserialize(); Invalid FPS in XAN";
|
||||
|
||||
SetFps(_fps);
|
||||
|
||||
int boneCount = 0;
|
||||
stream >> boneCount;
|
||||
if (boneCount < 0 || boneCount > s_maxBones)
|
||||
throw VERUS_RECOVERABLE << "Deserialize(), invalid number of bones in XAN";
|
||||
throw VERUS_RECOVERABLE << "Deserialize(); Invalid number of bones in XAN";
|
||||
|
||||
char buffer[IO::Stream::s_bufferSize] = {};
|
||||
VERUS_FOR(i, boneCount)
|
||||
|
|
|
@ -424,7 +424,7 @@ void Skeleton::LoadRigInfoFromPtr(SZ p)
|
|||
pugi::xml_document doc;
|
||||
const pugi::xml_parse_result result = doc.load_buffer_inplace(p, strlen(p));
|
||||
if (!result)
|
||||
throw VERUS_RECOVERABLE << "load_buffer_inplace(), " << result.description();
|
||||
throw VERUS_RECOVERABLE << "load_buffer_inplace(); " << result.description();
|
||||
pugi::xml_node root = doc.first_child();
|
||||
|
||||
if (auto node = root.child("mass"))
|
||||
|
|
|
@ -110,7 +110,7 @@ void Warp::LoadFromPtr(SZ p)
|
|||
pugi::xml_document doc;
|
||||
const pugi::xml_parse_result result = doc.load_buffer_inplace(p, strlen(p));
|
||||
if (!result)
|
||||
throw VERUS_RECOVERABLE << "load_buffer_inplace(), " << result.description();
|
||||
throw VERUS_RECOVERABLE << "load_buffer_inplace(); " << result.description();
|
||||
pugi::xml_node root = doc.first_child();
|
||||
|
||||
if (auto node = root.child("preview"))
|
||||
|
|
|
@ -220,9 +220,9 @@ void Settings::HandleHighDpi()
|
|||
if (FAILED(hr = SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE)))
|
||||
{
|
||||
if (E_ACCESSDENIED != hr)
|
||||
throw VERUS_RUNTIME_ERROR << "SetProcessDpiAwareness(), hr=" << VERUS_HR(hr);
|
||||
throw VERUS_RUNTIME_ERROR << "SetProcessDpiAwareness(); hr=" << VERUS_HR(hr);
|
||||
else
|
||||
VERUS_LOG_INFO("SetProcessDpiAwareness(), E_ACCESSDENIED");
|
||||
VERUS_LOG_INFO("SetProcessDpiAwareness(); E_ACCESSDENIED");
|
||||
}
|
||||
UpdateHighDpiScale();
|
||||
}
|
||||
|
@ -326,7 +326,7 @@ void Settings::LoadLocalizedStrings(CSZ url)
|
|||
pugi::xml_document doc;
|
||||
const pugi::xml_parse_result result = doc.load_buffer_inplace(vData.data(), vData.size());
|
||||
if (!result)
|
||||
throw VERUS_RECOVERABLE << "load_buffer_inplace(), " << result.description();
|
||||
throw VERUS_RECOVERABLE << "load_buffer_inplace(); " << result.description();
|
||||
pugi::xml_node root = doc.first_child();
|
||||
|
||||
_mapLocalizedStrings.clear();
|
||||
|
@ -353,7 +353,7 @@ void Settings::UpdateHighDpiScale()
|
|||
float vdpi = 0;
|
||||
if (SDL_GetDisplayDPI(0, &ddpi, &hdpi, &vdpi) < 0)
|
||||
{
|
||||
VERUS_LOG_INFO("SDL_GetDisplayDPI(), " << SDL_GetError());
|
||||
VERUS_LOG_INFO("SDL_GetDisplayDPI(); " << SDL_GetError());
|
||||
_highDpiScale = 1;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -56,7 +56,7 @@ void Window::Init(RcDesc constDesc)
|
|||
desc._height,
|
||||
flags);
|
||||
if (!_pWnd)
|
||||
throw VERUS_RECOVERABLE << "SDL_CreateWindow(), " << SDL_GetError();
|
||||
throw VERUS_RECOVERABLE << "SDL_CreateWindow(); " << SDL_GetError();
|
||||
|
||||
if (DisplayMode::exclusiveFullscreen == desc._displayMode || DisplayMode::borderlessWindowed == desc._displayMode)
|
||||
{
|
||||
|
|
|
@ -26,10 +26,10 @@ void AudioSystem::Init()
|
|||
throw VERUS_RUNTIME_ERROR << "alcOpenDevice()";
|
||||
|
||||
if (!(_pContext = alcCreateContext(_pDevice, nullptr)))
|
||||
throw VERUS_RUNTIME_ERROR << "alcCreateContext(), " << alcGetError(_pDevice);
|
||||
throw VERUS_RUNTIME_ERROR << "alcCreateContext(); " << alcGetError(_pDevice);
|
||||
|
||||
if (!alcMakeContextCurrent(_pContext))
|
||||
throw VERUS_RUNTIME_ERROR << "alcMakeContextCurrent(), " << alcGetError(_pDevice);
|
||||
throw VERUS_RUNTIME_ERROR << "alcMakeContextCurrent(); " << alcGetError(_pDevice);
|
||||
|
||||
int vMajor = 0, vMinor = 0;
|
||||
alcGetIntegerv(_pDevice, ALC_MAJOR_VERSION, sizeof(vMajor), &vMajor);
|
||||
|
|
|
@ -65,7 +65,7 @@ void Sound::Async_WhenLoaded(CSZ url, RcBlob blob)
|
|||
vorbis_info* povi;
|
||||
const int ret = ov_open_callbacks(&oggds, &ovf, 0, 0, g_oggCallbacks);
|
||||
if (ret < 0)
|
||||
throw VERUS_RUNTIME_ERROR << "ov_open_callbacks(), " << ret;
|
||||
throw VERUS_RUNTIME_ERROR << "ov_open_callbacks(); " << ret;
|
||||
|
||||
povi = ov_info(&ovf, -1);
|
||||
const ALenum format = (povi->channels == 1) ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16;
|
||||
|
|
|
@ -26,28 +26,28 @@ namespace verus
|
|||
ALuint _buffer = 0;
|
||||
int _next = 0;
|
||||
int _refCount = 0;
|
||||
Range<float> _gain = 1;
|
||||
Range<float> _pitch = 1;
|
||||
Interval _gain = 1;
|
||||
Interval _pitch = 1;
|
||||
float _length = 0;
|
||||
float _referenceDistance = 4;
|
||||
|
||||
public:
|
||||
struct Desc
|
||||
{
|
||||
CSZ _url = nullptr;
|
||||
Range<float> _gain = 0.8f;
|
||||
Range<float> _pitch = 1;
|
||||
float _referenceDistance = 4;
|
||||
bool _is3D = false;
|
||||
bool _loop = false;
|
||||
bool _randomOffset = false;
|
||||
bool _keepPcmBuffer = false;
|
||||
CSZ _url = nullptr;
|
||||
Interval _gain = 0.8f;
|
||||
Interval _pitch = 1;
|
||||
float _referenceDistance = 4;
|
||||
bool _is3D = false;
|
||||
bool _loop = false;
|
||||
bool _randomOffset = false;
|
||||
bool _keepPcmBuffer = false;
|
||||
|
||||
Desc(CSZ url) : _url(url) {}
|
||||
Desc& Set3D(bool b = true) { _is3D = b; return *this; }
|
||||
Desc& SetLoop(bool b = true) { _loop = b; return *this; }
|
||||
Desc& SetGain(const Range<float>& gain) { _gain = gain; return *this; }
|
||||
Desc& SetPitch(const Range<float>& pitch) { _pitch = pitch; return *this; }
|
||||
Desc& SetGain(Interval gain) { _gain = gain; return *this; }
|
||||
Desc& SetPitch(Interval pitch) { _pitch = pitch; return *this; }
|
||||
Desc& SetRandomOffset(bool b = true) { _randomOffset = b; return *this; }
|
||||
Desc& SetReferenceDistance(float rd) { _referenceDistance = rd; return *this; }
|
||||
};
|
||||
|
@ -70,8 +70,8 @@ namespace verus
|
|||
|
||||
SourcePtr NewSource(PSourcePtr pID = nullptr, Source::RcDesc desc = Source::Desc());
|
||||
|
||||
const Range<float>& GetGain() const { return _gain; }
|
||||
const Range<float>& GetPitch() const { return _pitch; }
|
||||
Interval GetGain() const { return _gain; }
|
||||
Interval GetPitch() const { return _pitch; }
|
||||
|
||||
float GetLength() const { return _length; }
|
||||
|
||||
|
|
|
@ -165,7 +165,7 @@ void StreamPlayer::SwitchToTrack(PTrack pTrack)
|
|||
|
||||
const int ret = ov_open_callbacks(_pTrack->GetOggDataSource(), &_oggVorbisFile, 0, 0, g_oggCallbacks);
|
||||
if (ret < 0)
|
||||
throw VERUS_RUNTIME_ERROR << "ov_open_callbacks(), " << ret;
|
||||
throw VERUS_RUNTIME_ERROR << "ov_open_callbacks(); " << ret;
|
||||
|
||||
_pVorbisInfo = ov_info(&_oggVorbisFile, -1);
|
||||
_format = (_pVorbisInfo->channels == 1) ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16;
|
||||
|
@ -246,7 +246,7 @@ void StreamPlayer::ThreadProc()
|
|||
|
||||
#ifdef _DEBUG
|
||||
char debug[80];
|
||||
sprintf_s(debug, "ThreadProc() processed=%d", processed);
|
||||
sprintf_s(debug, "ThreadProc(); processed=%d", processed);
|
||||
VERUS_LOG_DEBUG(debug);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace verus
|
|||
virtual void PushConstants(ShaderPtr shader, int offset, int size, const void* p, ShaderStageFlags stageFlags = ShaderStageFlags::vs_fs) = 0;
|
||||
|
||||
virtual void PipelineImageMemoryBarrier(TexturePtr tex, ImageLayout oldLayout, ImageLayout newLayout,
|
||||
Range<int> mipLevels, int arrayLayer = 0) = 0;
|
||||
Range mipLevels, int arrayLayer = 0) = 0;
|
||||
|
||||
virtual void Draw(int vertexCount, int instanceCount = 1, int firstVertex = 0, int firstInstance = 0) = 0;
|
||||
virtual void DrawIndexed(int indexCount, int instanceCount = 1, int firstIndex = 0, int vertexOffset = 0, int firstInstance = 0) = 0;
|
||||
|
|
|
@ -51,7 +51,7 @@ void Particles::Init(CSZ url)
|
|||
pugi::xml_document doc;
|
||||
const pugi::xml_parse_result result = doc.load_buffer_inplace(vData.data(), vData.size());
|
||||
if (!result)
|
||||
throw VERUS_RECOVERABLE << "load_buffer_inplace(), " << result.description();
|
||||
throw VERUS_RECOVERABLE << "load_buffer_inplace(); " << result.description();
|
||||
pugi::xml_node root = doc.first_child();
|
||||
|
||||
_capacity = root.child("capacity").text().as_int();
|
||||
|
|
|
@ -50,7 +50,7 @@ void ConvertGLTF::ParseData(CSZ pathname)
|
|||
const String baseDir = IO::FileSystem::ReplaceFilename(pathname, "");
|
||||
std::string err, warn;
|
||||
if (!_context.LoadASCIIFromString(&_model, &err, &warn, _vData.data(), Utils::Cast32(_vData.size()), _C(baseDir)))
|
||||
throw VERUS_RECOVERABLE << "LoadASCIIFromString() failed, err=" << err << ", warn=" << warn;
|
||||
throw VERUS_RECOVERABLE << "LoadASCIIFromString(); err=" << err << ", warn=" << warn;
|
||||
|
||||
_vNodeExtraData.resize(_model.nodes.size());
|
||||
const auto& scene = _model.scenes[_model.defaultScene];
|
||||
|
@ -98,7 +98,7 @@ void ConvertGLTF::SerializeAll(CSZ pathname)
|
|||
if (file.Open(path, "wb"))
|
||||
pMesh->SerializeX3D3(file);
|
||||
else
|
||||
throw VERUS_RECOVERABLE << "SerializeAll(), failed to create file: " << path;
|
||||
throw VERUS_RECOVERABLE << "SerializeAll(); Failed to create file: " << path;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ void ConvertGLTF::LoadFromFile(CSZ pathname)
|
|||
file.Read(_vData.data(), size);
|
||||
}
|
||||
else
|
||||
throw VERUS_RECOVERABLE << "LoadFromFile() failed, " << pathname;
|
||||
throw VERUS_RECOVERABLE << "LoadFromFile(); " << pathname;
|
||||
}
|
||||
|
||||
void ConvertGLTF::ProcessNodeRecursive(const tinygltf::Node& node, int nodeIndex, bool computeExtraData)
|
||||
|
|
|
@ -55,7 +55,7 @@ void ConvertX::ParseData(CSZ pathname)
|
|||
StreamSkipWhitespace();
|
||||
StreamReadUntil(buffer, sizeof(buffer), VERUS_WHITESPACE); // xof.
|
||||
if (strcmp(buffer, "xof"))
|
||||
throw VERUS_RECOVERABLE << "ParseData(), invalid file format (no xof)";
|
||||
throw VERUS_RECOVERABLE << "ParseData(); Invalid file format (no xof)";
|
||||
StreamSkipWhitespace();
|
||||
StreamReadUntil(buffer, sizeof(buffer), VERUS_WHITESPACE); // 0303txt.
|
||||
StreamSkipWhitespace();
|
||||
|
@ -182,7 +182,7 @@ void ConvertX::SerializeAll(CSZ pathname)
|
|||
if (file.Open(path, "wb"))
|
||||
pMesh->SerializeX3D3(file);
|
||||
else
|
||||
throw VERUS_RECOVERABLE << "SerializeAll(), failed to create file: " << path;
|
||||
throw VERUS_RECOVERABLE << "SerializeAll(); Failed to create file: " << path;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -239,7 +239,7 @@ void ConvertX::LoadFromFile(CSZ pathname)
|
|||
_pData = _vData.data();
|
||||
}
|
||||
else
|
||||
throw VERUS_RECOVERABLE << "LoadFromFile() failed, " << pathname;
|
||||
throw VERUS_RECOVERABLE << "LoadFromFile(); " << pathname;
|
||||
}
|
||||
|
||||
void ConvertX::StreamReadUntil(SZ dest, int destSize, CSZ separator)
|
||||
|
@ -247,7 +247,7 @@ void ConvertX::StreamReadUntil(SZ dest, int destSize, CSZ separator)
|
|||
memset(dest, 0, destSize);
|
||||
size_t len = strcspn(_pData, separator);
|
||||
if (int(len) >= destSize)
|
||||
throw VERUS_RECOVERABLE << "StreamReadUntil() failed, dest=" << destSize << ", length=" << len;
|
||||
throw VERUS_RECOVERABLE << "StreamReadUntil(); dest=" << destSize << ", length=" << len;
|
||||
strncpy(dest, _pData, len);
|
||||
_pData += len;
|
||||
}
|
||||
|
@ -350,7 +350,7 @@ void ConvertX::ParseBlockRecursive(CSZ type, CSZ blockName)
|
|||
{
|
||||
case '{':
|
||||
{
|
||||
throw VERUS_RECOVERABLE << "ParseBlockRecursive(), unexpected symbol \"{\" found in Mesh block";
|
||||
throw VERUS_RECOVERABLE << "ParseBlockRecursive(); Unexpected symbol \"{\" found in Mesh block";
|
||||
}
|
||||
break;
|
||||
case '}':
|
||||
|
@ -558,7 +558,7 @@ void ConvertX::ParseBlockData_Mesh()
|
|||
StreamSkipWhitespace();
|
||||
|
||||
if (Math::IsNaN(v.x) || Math::IsNaN(v.y) || Math::IsNaN(v.z))
|
||||
throw VERUS_RECOVERABLE << "ParseBlockData_Mesh(), NaN found";
|
||||
throw VERUS_RECOVERABLE << "ParseBlockData_Mesh(); NaN found";
|
||||
|
||||
// Collapse transformations:
|
||||
if (_desc._convertAsScene)
|
||||
|
@ -600,7 +600,7 @@ void ConvertX::ParseBlockData_Mesh()
|
|||
std::swap(order[1], order[2]);
|
||||
const int count = atoi(_pData); StreamSkipUntil(';'); _pData++;
|
||||
if (3 != count)
|
||||
throw VERUS_RECOVERABLE << "ParseBlockData_Mesh(), only triangles are supported, triangulate the quads";
|
||||
throw VERUS_RECOVERABLE << "ParseBlockData_Mesh(); Only triangles are supported, triangulate the quads";
|
||||
indices[order[0]] = atoi(_pData); StreamSkipUntil(','); _pData++;
|
||||
indices[order[1]] = atoi(_pData); StreamSkipUntil(','); _pData++;
|
||||
indices[order[2]] = atoi(_pData); StreamSkipUntil(';');
|
||||
|
@ -650,7 +650,7 @@ void ConvertX::ParseBlockData_MeshTextureCoords()
|
|||
const int vertCount = atoi(buffer);
|
||||
const int vertEdge = vertCount - 1;
|
||||
if (_pCurrentMesh->GetVertCount() != vertCount)
|
||||
throw VERUS_RECOVERABLE << "ParseBlockData_MeshTextureCoords(), different vertex count (" << vertCount << ")";
|
||||
throw VERUS_RECOVERABLE << "ParseBlockData_MeshTextureCoords(); Different vertex count (" << vertCount << ")";
|
||||
VERUS_FOR(i, vertCount)
|
||||
{
|
||||
OnProgress(float(i) / vertCount * 100);
|
||||
|
@ -661,7 +661,7 @@ void ConvertX::ParseBlockData_MeshTextureCoords()
|
|||
StreamSkipWhitespace();
|
||||
|
||||
if (Math::IsNaN(tc.x) || Math::IsNaN(tc.y))
|
||||
throw VERUS_RECOVERABLE << "ParseBlockData_MeshTextureCoords(), NaN found";
|
||||
throw VERUS_RECOVERABLE << "ParseBlockData_MeshTextureCoords(); NaN found";
|
||||
|
||||
_pCurrentMesh->GetSetVertexAt(i)._tc0 = tc;
|
||||
}
|
||||
|
@ -719,7 +719,7 @@ void ConvertX::ParseBlockData_MeshNormals()
|
|||
StreamSkipWhitespace();
|
||||
|
||||
if (Math::IsNaN(vNormals[i].x) || Math::IsNaN(vNormals[i].y) || Math::IsNaN(vNormals[i].z))
|
||||
throw VERUS_RECOVERABLE << "ParseBlockData_MeshNormals(), NaN found";
|
||||
throw VERUS_RECOVERABLE << "ParseBlockData_MeshNormals(); NaN found";
|
||||
|
||||
// Collapse transformations (no translation here):
|
||||
if (_desc._convertAsScene)
|
||||
|
@ -748,7 +748,7 @@ void ConvertX::ParseBlockData_MeshNormals()
|
|||
const int faceCount = atoi(buffer);
|
||||
const int faceEdge = faceCount - 1;
|
||||
if (_pCurrentMesh->GetFaceCount() != faceCount)
|
||||
throw VERUS_RECOVERABLE << "ParseBlockData_MeshNormals(), different face count (" << faceCount << ")";
|
||||
throw VERUS_RECOVERABLE << "ParseBlockData_MeshNormals(); Different face count (" << faceCount << ")";
|
||||
VERUS_FOR(i, faceCount)
|
||||
{
|
||||
OnProgress(float(i) / faceCount * 50 + 50);
|
||||
|
@ -805,7 +805,7 @@ void ConvertX::ParseBlockData_FVFData(bool declData)
|
|||
StreamReadUntil(buffer, sizeof(buffer), ";");
|
||||
_pData++; // Skip ";"
|
||||
if (atoi(buffer) != 258)
|
||||
throw VERUS_RECOVERABLE << "ParseBlockData_FVFData(), FVFData is not extra texture coords";
|
||||
throw VERUS_RECOVERABLE << "ParseBlockData_FVFData(); FVFData is not extra texture coords";
|
||||
}
|
||||
StreamSkipWhitespace();
|
||||
|
||||
|
@ -815,7 +815,7 @@ void ConvertX::ParseBlockData_FVFData(bool declData)
|
|||
const int vertCount = _pCurrentMesh->GetVertCount();
|
||||
const int vertEdge = vertCount - 1;
|
||||
if (atoi(buffer) != _pCurrentMesh->GetVertCount() * 2)
|
||||
throw VERUS_RECOVERABLE << "ParseBlockData_FVFData(), different vertex count";
|
||||
throw VERUS_RECOVERABLE << "ParseBlockData_FVFData(); Different vertex count";
|
||||
glm::vec2 tcPrev;
|
||||
bool trash = true;
|
||||
VERUS_FOR(i, vertCount)
|
||||
|
@ -936,7 +936,7 @@ void ConvertX::ParseBlockData_SkinWeights()
|
|||
StreamSkipWhitespace();
|
||||
bone._trToBoneSpace[i][j] = (float)atof(buffer);
|
||||
if (Math::IsNaN(bone._trToBoneSpace[i][j]))
|
||||
throw VERUS_RECOVERABLE << "ParseBlockData_SkinWeights(), NaN found";
|
||||
throw VERUS_RECOVERABLE << "ParseBlockData_SkinWeights(); NaN found";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -970,7 +970,7 @@ void ConvertX::ParseBlockData_Frame(CSZ blockName)
|
|||
{
|
||||
case '{':
|
||||
{
|
||||
throw VERUS_RECOVERABLE << "ParseBlockData_Frame(), unexpected symbol \"{\" found in Frame block";
|
||||
throw VERUS_RECOVERABLE << "ParseBlockData_Frame(); Unexpected symbol \"{\" found in Frame block";
|
||||
}
|
||||
break;
|
||||
case '}':
|
||||
|
@ -1052,7 +1052,7 @@ void ConvertX::ParseBlockData_FrameTransformMatrix()
|
|||
StreamSkipWhitespace();
|
||||
trLocal[i][j] = static_cast<float>(atof(buffer));
|
||||
if (Math::IsNaN(trLocal[i][j]))
|
||||
throw VERUS_RECOVERABLE << "ParseBlockData_FrameTransformMatrix(), NaN found";
|
||||
throw VERUS_RECOVERABLE << "ParseBlockData_FrameTransformMatrix(); NaN found";
|
||||
}
|
||||
}
|
||||
_pData++; // Skip ";"
|
||||
|
|
|
@ -77,7 +77,7 @@ void Cursor::MoveBy(float x, float y)
|
|||
|
||||
VERUS_QREF_CONST_SETTINGS;
|
||||
|
||||
const float scale = Game::BaseGame::GetMouseScale();
|
||||
const float scale = Input::InputManager::GetMouseScale();
|
||||
const float invScale = 1 / scale;
|
||||
_x = Math::Clamp<float>(_x + x * (invScale / settings._displaySizeWidth), 0, 1);
|
||||
_y = Math::Clamp<float>(_y + y * (invScale / settings._displaySizeHeight), 0, 1);
|
||||
|
|
|
@ -48,7 +48,7 @@ void Font::Init(CSZ url)
|
|||
pugi::xml_document doc;
|
||||
const pugi::xml_parse_result result = doc.load_buffer_inplace(vData.data(), vData.size());
|
||||
if (!result)
|
||||
throw VERUS_RECOVERABLE << "load_buffer_inplace(), " << result.description();
|
||||
throw VERUS_RECOVERABLE << "load_buffer_inplace(); " << result.description();
|
||||
pugi::xml_node root = doc.first_child();
|
||||
|
||||
pugi::xml_node commonNode = root.child("common");
|
||||
|
|
|
@ -88,10 +88,10 @@ void ViewManager::HandleInput()
|
|||
{
|
||||
if (!_vViews.empty())
|
||||
{
|
||||
VERUS_QREF_KM;
|
||||
if (km.IsMouseDownEvent(SDL_BUTTON_LEFT))
|
||||
VERUS_QREF_IM;
|
||||
if (im.IsMouseDownEvent(SDL_BUTTON_LEFT))
|
||||
_vViews[0]->OnClick();
|
||||
if (km.IsMouseDoubleClick(SDL_BUTTON_LEFT))
|
||||
if (im.IsMouseDoubleClick(SDL_BUTTON_LEFT))
|
||||
_vViews[0]->OnDoubleClick();
|
||||
}
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ PView ViewManager::ParseView(CSZ url)
|
|||
pugi::xml_document doc;
|
||||
const pugi::xml_parse_result result = doc.load_buffer_inplace(vData.data(), vData.size(), pugi::parse_default & ~pugi::parse_wconv_attribute);
|
||||
if (!result)
|
||||
throw VERUS_RECOVERABLE << "load_buffer_inplace(), " << result.description();
|
||||
throw VERUS_RECOVERABLE << "load_buffer_inplace(); " << result.description();
|
||||
pugi::xml_node root = doc.first_child();
|
||||
|
||||
PView pView = new View();
|
||||
|
|
|
@ -78,7 +78,7 @@ void BaseGame::Initialize(VERUS_MAIN_DEFAULT_ARGS, App::Window::RcDesc windowDes
|
|||
{
|
||||
const int ret = SDL_Init(SDL_INIT_EVERYTHING);
|
||||
if (ret)
|
||||
throw VERUS_RUNTIME_ERROR << "SDL_Init(), " << ret;
|
||||
throw VERUS_RUNTIME_ERROR << "SDL_Init(); " << ret;
|
||||
|
||||
Utils::I().InitPaths();
|
||||
|
||||
|
@ -104,7 +104,10 @@ void BaseGame::Initialize(VERUS_MAIN_DEFAULT_ARGS, App::Window::RcDesc windowDes
|
|||
|
||||
_window.Init(updatedWindowDesc);
|
||||
CGI::Renderer::I().SetMainWindow(&_window);
|
||||
_engineInit.Init(this, new MyRendererDelegate(this));
|
||||
_engineInit.Init(new MyRendererDelegate(this));
|
||||
|
||||
VERUS_QREF_IM;
|
||||
im.GainFocus(this);
|
||||
|
||||
// Configure:
|
||||
VERUS_QREF_RENDERER;
|
||||
|
@ -125,10 +128,10 @@ void BaseGame::Initialize(VERUS_MAIN_DEFAULT_ARGS, App::Window::RcDesc windowDes
|
|||
renderer->Sync(false);
|
||||
}
|
||||
|
||||
void BaseGame::Run(bool relativeMouseMode)
|
||||
void BaseGame::Loop(bool relativeMouseMode)
|
||||
{
|
||||
VERUS_QREF_ASYNC;
|
||||
VERUS_QREF_KM;
|
||||
VERUS_QREF_IM;
|
||||
VERUS_QREF_RENDERER;
|
||||
VERUS_QREF_TIMER;
|
||||
|
||||
|
@ -190,7 +193,7 @@ void BaseGame::Run(bool relativeMouseMode)
|
|||
}
|
||||
}
|
||||
|
||||
if (!keyboardShortcut && !km.HandleSdlEvent(event))
|
||||
if (!keyboardShortcut && !im.HandleEvent(event))
|
||||
{
|
||||
switch (event.type)
|
||||
{
|
||||
|
@ -250,7 +253,7 @@ void BaseGame::Run(bool relativeMouseMode)
|
|||
}
|
||||
}
|
||||
|
||||
if (_p->_escapeKeyExitGame && km.IsKeyDownEvent(SDL_SCANCODE_ESCAPE))
|
||||
if (_p->_escapeKeyExitGame && im.IsKeyDownEvent(SDL_SCANCODE_ESCAPE))
|
||||
Exit();
|
||||
|
||||
if (_p->_minimized || _restartApp)
|
||||
|
@ -268,18 +271,18 @@ void BaseGame::Run(bool relativeMouseMode)
|
|||
|
||||
if (_p->_defaultCameraMovement)
|
||||
{
|
||||
const float speed = km.IsKeyPressed(SDL_SCANCODE_SPACE) ? 20.f : 2.f;
|
||||
if (km.IsKeyPressed(SDL_SCANCODE_W))
|
||||
const float speed = im.IsKeyPressed(SDL_SCANCODE_SPACE) ? 20.f : 2.f;
|
||||
if (im.IsKeyPressed(SDL_SCANCODE_W))
|
||||
_p->_cameraSpirit.MoveFront(speed);
|
||||
if (km.IsKeyPressed(SDL_SCANCODE_S))
|
||||
if (im.IsKeyPressed(SDL_SCANCODE_S))
|
||||
_p->_cameraSpirit.MoveFront(-speed);
|
||||
if (km.IsKeyPressed(SDL_SCANCODE_A))
|
||||
if (im.IsKeyPressed(SDL_SCANCODE_A))
|
||||
_p->_cameraSpirit.MoveSide(-speed);
|
||||
if (km.IsKeyPressed(SDL_SCANCODE_D))
|
||||
if (im.IsKeyPressed(SDL_SCANCODE_D))
|
||||
_p->_cameraSpirit.MoveSide(speed);
|
||||
}
|
||||
|
||||
BaseGame_HandleInput();
|
||||
im.HandleInput();
|
||||
if (_restartApp)
|
||||
continue;
|
||||
|
||||
|
@ -312,7 +315,7 @@ void BaseGame::Run(bool relativeMouseMode)
|
|||
|
||||
// Draw current frame:
|
||||
renderer.Draw();
|
||||
km.ResetClickState();
|
||||
im.ResetInputState();
|
||||
renderer->EndFrame();
|
||||
renderer.Present();
|
||||
renderer->Sync();
|
||||
|
@ -346,32 +349,15 @@ void BaseGame::Exit()
|
|||
Utils::PushQuitEvent();
|
||||
}
|
||||
|
||||
void BaseGame::KeyMapper_OnMouseMove(int x, int y)
|
||||
void BaseGame::OnMouseMove(float dx, float dy)
|
||||
{
|
||||
if (!SDL_GetRelativeMouseMode())
|
||||
return;
|
||||
|
||||
const float scale = GetMouseScale();
|
||||
const float fx = x * scale;
|
||||
const float fy = y * scale;
|
||||
|
||||
if (_p->_defaultCameraMovement)
|
||||
{
|
||||
_p->_cameraSpirit.TurnPitch(fy);
|
||||
_p->_cameraSpirit.TurnYaw(fx);
|
||||
_p->_cameraSpirit.TurnPitch(dy);
|
||||
_p->_cameraSpirit.TurnYaw(dx);
|
||||
}
|
||||
|
||||
BaseGame_OnMouseMove(fx, fy);
|
||||
}
|
||||
|
||||
void BaseGame::KeyMapper_OnKey(int scancode)
|
||||
{
|
||||
BaseGame_OnKey(scancode);
|
||||
}
|
||||
|
||||
void BaseGame::KeyMapper_OnChar(wchar_t c)
|
||||
{
|
||||
BaseGame_OnChar(c);
|
||||
}
|
||||
|
||||
bool BaseGame::IsFullscreen() const
|
||||
|
@ -423,13 +409,6 @@ void BaseGame::BulletDebugDraw()
|
|||
bullet.DebugDraw();
|
||||
}
|
||||
|
||||
float BaseGame::GetMouseScale()
|
||||
{
|
||||
VERUS_QREF_CONST_SETTINGS;
|
||||
const float rad = (VERUS_2PI / 360.f) / 3.f; // 3 pixels = 1 degree.
|
||||
return rad * settings._inputMouseSensitivity;
|
||||
}
|
||||
|
||||
void BaseGame::RestartApp()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace verus
|
|||
{
|
||||
namespace Game
|
||||
{
|
||||
class BaseGame : public Input::KeyMapperDelegate
|
||||
class BaseGame : public Input::InputFocus
|
||||
{
|
||||
struct Pimpl;
|
||||
Pimpl* _p = nullptr;
|
||||
|
@ -19,13 +19,12 @@ namespace verus
|
|||
~BaseGame();
|
||||
|
||||
void Initialize(VERUS_MAIN_DEFAULT_ARGS, App::Window::RcDesc windowDesc = App::Window::Desc());
|
||||
void Run(bool relativeMouseMode = true);
|
||||
void Loop(bool relativeMouseMode = true);
|
||||
void Exit();
|
||||
|
||||
virtual void BaseGame_UpdateSettings(App::Window::RDesc windowDesc) {}
|
||||
virtual void BaseGame_LoadContent() = 0;
|
||||
virtual void BaseGame_UnloadContent() = 0;
|
||||
virtual void BaseGame_HandleInput() = 0;
|
||||
virtual void BaseGame_Update() = 0;
|
||||
virtual void BaseGame_Draw() = 0;
|
||||
virtual void BaseGame_DrawOverlay() {}
|
||||
|
@ -33,9 +32,6 @@ namespace verus
|
|||
virtual void BaseGame_OnWindowSizeChanged() {}
|
||||
virtual void BaseGame_OnActivated() {}
|
||||
virtual void BaseGame_OnDeactivated() {}
|
||||
virtual void BaseGame_OnMouseMove(float x, float y) {}
|
||||
virtual void BaseGame_OnKey(int scancode) {}
|
||||
virtual void BaseGame_OnChar(wchar_t c) {}
|
||||
virtual bool BaseGame_CanQuitEventLoop() { return true; }
|
||||
|
||||
// Raw SDL events, for editor:
|
||||
|
@ -46,9 +42,7 @@ namespace verus
|
|||
virtual void BaseGame_SDL_OnMouseWheel(int delta) {}
|
||||
virtual bool BaseGame_SDL_OnKeyboardShortcut(int sym, int mod) { return false; }
|
||||
|
||||
virtual void KeyMapper_OnMouseMove(int x, int y) override;
|
||||
virtual void KeyMapper_OnKey(int scancode) override;
|
||||
virtual void KeyMapper_OnChar(wchar_t c) override;
|
||||
virtual void OnMouseMove(float dx, float dy) override;
|
||||
|
||||
REngineInit GetEngineInit() { return _engineInit; }
|
||||
|
||||
|
@ -68,8 +62,6 @@ namespace verus
|
|||
|
||||
void BulletDebugDraw();
|
||||
|
||||
static float GetMouseScale();
|
||||
|
||||
bool IsRestartAppRequested() const { return _restartApp; }
|
||||
void RestartApp();
|
||||
void RequestAppRestart();
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
// Copyright (C) 2021, Dmitry Maluev (dmaluev@gmail.com). All rights reserved.
|
||||
#include "verus.h"
|
||||
|
||||
using namespace verus;
|
||||
using namespace verus::Game;
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright (C) 2021, Dmitry Maluev (dmaluev@gmail.com). All rights reserved.
|
||||
#pragma once
|
||||
|
||||
namespace verus
|
||||
{
|
||||
namespace Game
|
||||
{
|
||||
class Component
|
||||
{
|
||||
};
|
||||
VERUS_TYPEDEFS(Component);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
// Copyright (C) 2021, Dmitry Maluev (dmaluev@gmail.com). All rights reserved.
|
||||
#include "verus.h"
|
||||
|
||||
using namespace verus;
|
||||
using namespace verus::Game;
|
||||
|
||||
Entity::Entity()
|
||||
{
|
||||
}
|
||||
|
||||
Entity::~Entity()
|
||||
{
|
||||
Done();
|
||||
}
|
||||
|
||||
void Entity::Init()
|
||||
{
|
||||
if (_refCount)
|
||||
return;
|
||||
|
||||
VERUS_INIT();
|
||||
_refCount = 1;
|
||||
}
|
||||
|
||||
bool Entity::Done()
|
||||
{
|
||||
_refCount--;
|
||||
if (_refCount <= 0)
|
||||
{
|
||||
VERUS_DONE(Entity);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
// Copyright (C) 2021, Dmitry Maluev (dmaluev@gmail.com). All rights reserved.
|
||||
#pragma once
|
||||
|
||||
namespace verus
|
||||
{
|
||||
namespace Game
|
||||
{
|
||||
class Entity : public Object
|
||||
{
|
||||
int _refCount = 0;
|
||||
|
||||
public:
|
||||
Entity();
|
||||
~Entity();
|
||||
|
||||
void Init();
|
||||
bool Done();
|
||||
|
||||
void AddRef() { _refCount++; }
|
||||
int GetRefCount() const { return _refCount; }
|
||||
};
|
||||
VERUS_TYPEDEFS(Entity);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
// Copyright (C) 2021, Dmitry Maluev (dmaluev@gmail.com). All rights reserved.
|
||||
#include "verus.h"
|
||||
|
||||
using namespace verus;
|
||||
using namespace verus::Game;
|
||||
|
||||
Lot::Lot()
|
||||
{
|
||||
}
|
||||
|
||||
Lot::~Lot()
|
||||
{
|
||||
Done();
|
||||
}
|
||||
|
||||
void Lot::Init()
|
||||
{
|
||||
if (_refCount)
|
||||
return;
|
||||
|
||||
VERUS_INIT();
|
||||
_refCount = 1;
|
||||
}
|
||||
|
||||
bool Lot::Done()
|
||||
{
|
||||
_refCount--;
|
||||
if (_refCount <= 0)
|
||||
{
|
||||
VERUS_DONE(Lot);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
PEntity Lot::InsertEntity(CSZ uid)
|
||||
{
|
||||
return TStoreEntities::Insert(uid);
|
||||
}
|
||||
|
||||
PEntity Lot::FindEntity(CSZ uid)
|
||||
{
|
||||
return TStoreEntities::Find(uid);
|
||||
}
|
||||
|
||||
void Lot::DeleteEntity(CSZ uid)
|
||||
{
|
||||
TStoreEntities::Delete(uid);
|
||||
}
|
||||
|
||||
void Lot::DeleteAllEntities()
|
||||
{
|
||||
TStoreEntities::DeleteAll();
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
// Copyright (C) 2021, Dmitry Maluev (dmaluev@gmail.com). All rights reserved.
|
||||
#pragma once
|
||||
|
||||
namespace verus
|
||||
{
|
||||
namespace Game
|
||||
{
|
||||
typedef StoreUnique<String, Entity> TStoreEntities;
|
||||
class Lot : public Object, private TStoreEntities
|
||||
{
|
||||
int _refCount = 0;
|
||||
|
||||
public:
|
||||
Lot();
|
||||
~Lot();
|
||||
|
||||
void Init();
|
||||
bool Done();
|
||||
|
||||
void AddRef() { _refCount++; }
|
||||
int GetRefCount() const { return _refCount; }
|
||||
|
||||
// Entities:
|
||||
PEntity InsertEntity(CSZ uid);
|
||||
PEntity FindEntity(CSZ uid);
|
||||
void DeleteEntity(CSZ uid);
|
||||
void DeleteAllEntities();
|
||||
template<typename T>
|
||||
void ForEachEntity(const T& fn)
|
||||
{
|
||||
VERUS_FOREACH_X(TStoreEntities::TMap, TStoreEntities::_map, it)
|
||||
{
|
||||
auto& entity = *it++;
|
||||
if (Continue::no == fn(entity.second))
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
VERUS_TYPEDEFS(Lot);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
// Copyright (C) 2021, Dmitry Maluev (dmaluev@gmail.com). All rights reserved.
|
||||
#include "verus.h"
|
||||
|
||||
using namespace verus;
|
||||
using namespace verus::Game;
|
||||
|
||||
LotManager::LotManager()
|
||||
{
|
||||
}
|
||||
|
||||
LotManager::~LotManager()
|
||||
{
|
||||
Done();
|
||||
}
|
||||
|
||||
void LotManager::Init()
|
||||
{
|
||||
VERUS_INIT();
|
||||
}
|
||||
|
||||
void LotManager::Done()
|
||||
{
|
||||
VERUS_DONE(LotManager);
|
||||
}
|
||||
|
||||
PLot LotManager::InsertLot(CSZ uid)
|
||||
{
|
||||
return TStoreLots::Insert(uid);
|
||||
}
|
||||
|
||||
PLot LotManager::FindLot(CSZ uid)
|
||||
{
|
||||
return TStoreLots::Find(uid);
|
||||
}
|
||||
|
||||
void LotManager::DeleteLot(CSZ uid)
|
||||
{
|
||||
TStoreLots::Delete(uid);
|
||||
}
|
||||
|
||||
void LotManager::DeleteAllLots()
|
||||
{
|
||||
TStoreLots::DeleteAll();
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
// Copyright (C) 2021, Dmitry Maluev (dmaluev@gmail.com). All rights reserved.
|
||||
#pragma once
|
||||
|
||||
namespace verus
|
||||
{
|
||||
namespace Game
|
||||
{
|
||||
typedef StoreUnique<String, Lot> TStoreLots;
|
||||
class LotManager : public Singleton<LotManager>, public Object, private TStoreLots
|
||||
{
|
||||
public:
|
||||
LotManager();
|
||||
virtual ~LotManager();
|
||||
|
||||
void Init();
|
||||
void Done();
|
||||
|
||||
// Lots:
|
||||
PLot InsertLot(CSZ uid);
|
||||
PLot FindLot(CSZ uid);
|
||||
void DeleteLot(CSZ uid);
|
||||
void DeleteAllLots();
|
||||
template<typename T>
|
||||
void ForEachLot(const T& fn)
|
||||
{
|
||||
VERUS_FOREACH_X(TStoreLots::TMap, TStoreLots::_map, it)
|
||||
{
|
||||
auto& lot = *it++;
|
||||
if (Continue::no == fn(lot.second))
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
VERUS_TYPEDEFS(LotManager);
|
||||
}
|
||||
}
|
|
@ -7,8 +7,12 @@
|
|||
#include "BaseCharacter.h"
|
||||
#include "BaseGame.h"
|
||||
#include "ChainAward.h"
|
||||
#include "Mechanics.h"
|
||||
#include "ActiveMechanics.h"
|
||||
#include "Driving.h"
|
||||
#include "Cutscene.h"
|
||||
#include "ECS/Component.h"
|
||||
#include "ECS/Entity.h"
|
||||
#include "ECS/Lot.h"
|
||||
#include "ECS/LotManager.h"
|
||||
#include "Mechanics/Mechanics.h"
|
||||
#include "Mechanics/ActiveMechanics.h"
|
||||
#include "Mechanics/Driving.h"
|
||||
#include "Mechanics/Cutscene.h"
|
||||
#include "QuestSystem.h"
|
||||
|
|
|
@ -345,7 +345,7 @@ void Cutscene::Load(CSZ url)
|
|||
pugi::xml_document doc;
|
||||
const pugi::xml_parse_result result = doc.load_buffer_inplace(vData.data(), vData.size());
|
||||
if (!result)
|
||||
throw VERUS_RECOVERABLE << "load_buffer_inplace(), " << result.description();
|
||||
throw VERUS_RECOVERABLE << "load_buffer_inplace(); " << result.description();
|
||||
pugi::xml_node root = doc.first_child();
|
||||
|
||||
_interactive = root.attribute("interactive").as_bool(_interactive);
|
||||
|
@ -363,7 +363,7 @@ void Cutscene::Load(CSZ url)
|
|||
_vCommands.push_back(pCommand);
|
||||
}
|
||||
else
|
||||
throw VERUS_RECOVERABLE << "CreateCommand(), type=" << commandType;
|
||||
throw VERUS_RECOVERABLE << "CreateCommand(); type=" << commandType;
|
||||
}
|
||||
}
|
||||
|
|
@ -13,10 +13,6 @@ void State::OnEnter(PState pPrev)
|
|||
{
|
||||
}
|
||||
|
||||
void State::HandleInput()
|
||||
{
|
||||
}
|
||||
|
||||
void State::Update()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ namespace verus
|
|||
|
||||
virtual bool IsValidNextState(State* p);
|
||||
virtual void OnEnter(State* pPrev);
|
||||
virtual void HandleInput();
|
||||
virtual void Update();
|
||||
virtual void Draw();
|
||||
virtual void OnExit(State* pNext);
|
||||
|
|
|
@ -4,14 +4,6 @@
|
|||
using namespace verus;
|
||||
using namespace verus::Game;
|
||||
|
||||
void StateMachine::HandleInput()
|
||||
{
|
||||
PcState pCheck = _pCurrentState;
|
||||
_pCurrentState->SetStateMachine(this);
|
||||
_pCurrentState->HandleInput();
|
||||
_changed = (_pCurrentState != pCheck);
|
||||
}
|
||||
|
||||
void StateMachine::Update()
|
||||
{
|
||||
VERUS_UPDATE_ONCE_CHECK;
|
||||
|
|
|
@ -13,7 +13,6 @@ namespace verus
|
|||
bool _changed = false;
|
||||
|
||||
public:
|
||||
void HandleInput();
|
||||
void Update();
|
||||
void Draw();
|
||||
|
||||
|
|
|
@ -199,7 +199,7 @@ UINT32 Convert::ColorTextToInt32(CSZ sz)
|
|||
UINT16 Convert::QuantizeFloat(float f, float mn, float mx)
|
||||
{
|
||||
const float range = mx - mn;
|
||||
return UINT16(Math::Clamp((f - mn) / range * USHRT_MAX, 0.f, float(USHRT_MAX)));
|
||||
return UINT16(Math::Clamp<float>((f - mn) / range * USHRT_MAX + 0.5f, 0, USHRT_MAX));
|
||||
}
|
||||
|
||||
float Convert::DequantizeFloat(UINT16 i, float mn, float mx)
|
||||
|
@ -211,7 +211,7 @@ float Convert::DequantizeFloat(UINT16 i, float mn, float mx)
|
|||
BYTE Convert::QuantizeFloatToByte(float f, float mn, float mx)
|
||||
{
|
||||
const float range = mx - mn;
|
||||
return BYTE(Math::Clamp((f - mn) / range * UCHAR_MAX, 0.f, float(UCHAR_MAX)));
|
||||
return BYTE(Math::Clamp<float>((f - mn) / range * UCHAR_MAX + 0.5f, 0, UCHAR_MAX));
|
||||
}
|
||||
|
||||
float Convert::DequantizeFloatFromByte(BYTE i, float mn, float mx)
|
||||
|
@ -222,8 +222,7 @@ float Convert::DequantizeFloatFromByte(BYTE i, float mn, float mx)
|
|||
|
||||
String Convert::ToBase64(const Vector<BYTE>& vBin)
|
||||
{
|
||||
Vector<char> vBase64;
|
||||
vBase64.resize(vBin.size() * 2);
|
||||
Vector<char> vBase64(vBin.size() * 2);
|
||||
base64_encodestate state;
|
||||
base64_init_encodestate(&state);
|
||||
const int len = base64_encode_block(reinterpret_cast<CSZ>(vBin.data()), Utils::Cast32(vBin.size()), vBase64.data(), &state);
|
||||
|
@ -234,8 +233,7 @@ String Convert::ToBase64(const Vector<BYTE>& vBin)
|
|||
|
||||
Vector<BYTE> Convert::ToBinFromBase64(CSZ base64)
|
||||
{
|
||||
Vector<BYTE> vBin;
|
||||
vBin.resize(strlen(base64));
|
||||
Vector<BYTE> vBin(strlen(base64));
|
||||
base64_decodestate state;
|
||||
base64_init_decodestate(&state);
|
||||
const int len = base64_decode_block(base64, Utils::Cast32(strlen(base64)), reinterpret_cast<SZ>(vBin.data()), &state);
|
||||
|
@ -257,8 +255,7 @@ String Convert::ToHex(const Vector<BYTE>& vBin)
|
|||
{
|
||||
static const char hexval[] = "0123456789ABCDEF";
|
||||
const int count = Utils::Cast32(vBin.size());
|
||||
Vector<char> vHex;
|
||||
vHex.resize(count * 2);
|
||||
Vector<char> vHex(count * 2);
|
||||
VERUS_FOR(i, count)
|
||||
{
|
||||
vHex[(i << 1) + 0] = hexval[(vBin[i] >> 4) & 0xF];
|
||||
|
@ -363,8 +360,7 @@ void Convert::Test()
|
|||
VERUS_RT_ASSERT(colorIn[i] == colorTest[i]);
|
||||
}
|
||||
|
||||
Vector<BYTE> vBin;
|
||||
vBin.resize(16);
|
||||
Vector<BYTE> vBin(16);
|
||||
|
||||
Random random;
|
||||
random.NextArray(vBin);
|
||||
|
|
|
@ -56,7 +56,7 @@ void EngineInit::Free()
|
|||
Free_Global();
|
||||
}
|
||||
|
||||
void EngineInit::Init(Input::PKeyMapperDelegate pKeyMapperDelegate, CGI::RendererDelegate* pRendererDelegate)
|
||||
void EngineInit::Init(CGI::RendererDelegate* pRendererDelegate)
|
||||
{
|
||||
Timer::I().Init();
|
||||
|
||||
|
@ -69,10 +69,7 @@ void EngineInit::Init(Input::PKeyMapperDelegate pKeyMapperDelegate, CGI::Rendere
|
|||
if (_makePhysics)
|
||||
Physics::Bullet::I().Init();
|
||||
if (_makeInput)
|
||||
{
|
||||
Input::KeyMapper::I().Init();
|
||||
Input::KeyMapper::I().SetDelegate(pKeyMapperDelegate);
|
||||
}
|
||||
Input::InputManager::I().Init();
|
||||
|
||||
if (_makeCGI)
|
||||
CGI::Renderer::I().Init(pRendererDelegate, _allowInitShaders);
|
||||
|
|
|
@ -3,10 +3,6 @@
|
|||
|
||||
namespace verus
|
||||
{
|
||||
namespace Input
|
||||
{
|
||||
struct KeyMapperDelegate;
|
||||
}
|
||||
namespace CGI
|
||||
{
|
||||
struct RendererDelegate;
|
||||
|
@ -34,7 +30,7 @@ namespace verus
|
|||
void Make();
|
||||
void Free();
|
||||
|
||||
void Init(Input::KeyMapperDelegate* pKeyMapperDelegate, CGI::RendererDelegate* pRendererDelegate);
|
||||
void Init(CGI::RendererDelegate* pRendererDelegate);
|
||||
void InitCmd();
|
||||
|
||||
void ReducedFeatureSet();
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "Str.h"
|
||||
#include "Utils.h"
|
||||
#include "Parallel.h"
|
||||
#include "Interval.h"
|
||||
#include "Range.h"
|
||||
#include "Object.h"
|
||||
#include "Lockable.h"
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright (C) 2021, Dmitry Maluev (dmaluev@gmail.com). All rights reserved.
|
||||
#include "verus.h"
|
||||
|
||||
using namespace verus;
|
||||
|
||||
float Interval::GetLength() const
|
||||
{
|
||||
return _max - _min;
|
||||
}
|
||||
|
||||
float Interval::GetRandomValue() const
|
||||
{
|
||||
return _min + Utils::I().GetRandom().NextFloat() * GetLength();
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (C) 2021, Dmitry Maluev (dmaluev@gmail.com). All rights reserved.
|
||||
#pragma once
|
||||
|
||||
namespace verus
|
||||
{
|
||||
class Interval
|
||||
{
|
||||
public:
|
||||
float _min;
|
||||
float _max;
|
||||
|
||||
Interval() : _min(0), _max(0) {}
|
||||
Interval(float x) : _min(x), _max(x) {}
|
||||
Interval(float mn, float mx) : _min(mn), _max(mx) { VERUS_RT_ASSERT(_min <= _max); }
|
||||
|
||||
float GetLength() const;
|
||||
float GetRandomValue() const;
|
||||
};
|
||||
}
|
|
@ -13,7 +13,7 @@
|
|||
#define VERUS_QREF_FSYS IO::RFileSystem fsys = IO::FileSystem::I()
|
||||
#define VERUS_QREF_GRASS Scene::RGrass grass = Scene::Grass::I()
|
||||
#define VERUS_QREF_HELPERS Scene::RHelpers helpers = Scene::Helpers::I()
|
||||
#define VERUS_QREF_KM Input::RKeyMapper km = Input::KeyMapper::I()
|
||||
#define VERUS_QREF_IM Input::RInputManager im = Input::InputManager::I()
|
||||
#define VERUS_QREF_MM Scene::RMaterialManager mm = Scene::MaterialManager::I()
|
||||
#define VERUS_QREF_MP Net::RMultiplayer mp = Net::Multiplayer::I()
|
||||
#define VERUS_QREF_PHYSICS Physics::RPhysics physics = Physics::Physics::I()
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
// Copyright (C) 2021, Dmitry Maluev (dmaluev@gmail.com). All rights reserved.
|
||||
#include "verus.h"
|
||||
|
||||
using namespace verus;
|
||||
|
||||
int Range::GetCount() const
|
||||
{
|
||||
return _end - _begin;
|
||||
}
|
||||
|
||||
int Range::GetRandomValue() const
|
||||
{
|
||||
const int count = GetCount();
|
||||
if (count > 0)
|
||||
return Utils::I().GetRandom().Next(_begin, _end - 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Range& Range::OffsetBy(int x)
|
||||
{
|
||||
_begin += x;
|
||||
_end += x;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Range::Iterator Range::begin() const
|
||||
{
|
||||
return _begin;
|
||||
}
|
||||
|
||||
Range::Iterator Range::end() const
|
||||
{
|
||||
return _end;
|
||||
}
|
|
@ -3,33 +3,33 @@
|
|||
|
||||
namespace verus
|
||||
{
|
||||
template<typename T>
|
||||
class Range
|
||||
{
|
||||
public:
|
||||
class Iterator
|
||||
{
|
||||
T _value;
|
||||
int _value;
|
||||
|
||||
public:
|
||||
Iterator(T x) : _value(x) {}
|
||||
Iterator(int x) : _value(x) {}
|
||||
|
||||
T& operator*() { return _value; }
|
||||
int& operator*() { return _value; }
|
||||
Iterator operator++() { ++_value; return *this; }
|
||||
bool operator!=(const Iterator& that) const { return _value != that._value; }
|
||||
};
|
||||
|
||||
T _min;
|
||||
T _max;
|
||||
int _begin;
|
||||
int _end;
|
||||
|
||||
Range() : _min(0), _max(0) {}
|
||||
Range(T x) : _min(x), _max(x) {}
|
||||
Range(T mn, T mx) : _min(mn), _max(mx) { VERUS_RT_ASSERT(_min <= _max); }
|
||||
Range() : _begin(0), _end(0) {}
|
||||
Range(int x) : _begin(x), _end(x + 1) {}
|
||||
Range(int b, int e) : _begin(b), _end(e) { VERUS_RT_ASSERT(_begin <= _end); }
|
||||
|
||||
T GetLength() const { return _max - _min; }
|
||||
T GetRandomValue() const { return _min + Utils::I().GetRandom().NextFloat() * GetLength(); }
|
||||
int GetCount() const;
|
||||
int GetRandomValue() const;
|
||||
Range& OffsetBy(int x);
|
||||
|
||||
Iterator begin() const { return _min; }
|
||||
Iterator end() const { return _max + 1; }
|
||||
Iterator begin() const;
|
||||
Iterator end() const;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ void Async::Update()
|
|||
if (task._loaded) // Only loaded task can be processed:
|
||||
{
|
||||
#ifdef VERUS_RELEASE_DEBUG
|
||||
VERUS_LOG_DEBUG("Update() task=" << itTask->first);
|
||||
VERUS_LOG_DEBUG("Update(); task=" << itTask->first);
|
||||
#endif
|
||||
VERUS_RT_ASSERT(task._desc._runOnMainThread);
|
||||
if (!task._v.empty())
|
||||
|
@ -218,7 +218,7 @@ void Async::ThreadProc()
|
|||
}
|
||||
|
||||
#ifdef VERUS_RELEASE_DEBUG
|
||||
VERUS_LOG_DEBUG("ThreadProc() key=" << key);
|
||||
VERUS_LOG_DEBUG("ThreadProc(); key=" << key);
|
||||
#endif
|
||||
|
||||
{
|
||||
|
@ -229,7 +229,7 @@ void Async::ThreadProc()
|
|||
if (!pTask->_desc._runOnMainThread)
|
||||
{
|
||||
#ifdef VERUS_RELEASE_DEBUG
|
||||
VERUS_LOG_DEBUG("ThreadProc(), runOnMainThread key=" << key);
|
||||
VERUS_LOG_DEBUG("ThreadProc(); runOnMainThread key=" << key);
|
||||
#endif
|
||||
if (!pTask->_v.empty())
|
||||
{
|
||||
|
|
|
@ -38,17 +38,17 @@ void Dictionary::LinkParent(PDictionary p)
|
|||
_pParent = p;
|
||||
}
|
||||
|
||||
void Dictionary::Insert(CSZ name, CSZ value)
|
||||
void Dictionary::Insert(CSZ key, CSZ value)
|
||||
{
|
||||
if (!name || !strlen(name) || !value)
|
||||
if (!key || !strlen(key) || !value)
|
||||
return;
|
||||
PDictionaryValue p = TStoreValues::Insert(name);
|
||||
PDictionaryValue p = TStoreValues::Insert(key);
|
||||
p->Set(value);
|
||||
}
|
||||
|
||||
void Dictionary::Delete(CSZ name)
|
||||
void Dictionary::Delete(CSZ key)
|
||||
{
|
||||
TStoreValues::Delete(name);
|
||||
TStoreValues::Delete(key);
|
||||
}
|
||||
|
||||
void Dictionary::DeleteAll()
|
||||
|
@ -56,40 +56,40 @@ void Dictionary::DeleteAll()
|
|||
TStoreValues::DeleteAll();
|
||||
}
|
||||
|
||||
CSZ Dictionary::Find(CSZ name, CSZ def) const
|
||||
CSZ Dictionary::Find(CSZ key, CSZ def) const
|
||||
{
|
||||
VERUS_IF_FOUND_IN(TStoreValues::TMap, TStoreValues::_map, name, it)
|
||||
VERUS_IF_FOUND_IN(TStoreValues::TMap, TStoreValues::_map, key, it)
|
||||
return _C(it->second._s);
|
||||
if (_pParent)
|
||||
return _pParent->Find(name, def);
|
||||
return _pParent->Find(key, def);
|
||||
return def;
|
||||
}
|
||||
|
||||
RcString Dictionary::FindSafe(CSZ name) const
|
||||
RcString Dictionary::FindSafe(CSZ key) const
|
||||
{
|
||||
VERUS_IF_FOUND_IN(TStoreValues::TMap, TStoreValues::_map, name, it)
|
||||
VERUS_IF_FOUND_IN(TStoreValues::TMap, TStoreValues::_map, key, it)
|
||||
return it->second._s;
|
||||
if (_pParent)
|
||||
return _pParent->FindSafe(name);
|
||||
return _pParent->FindSafe(key);
|
||||
static String null;
|
||||
return null;
|
||||
}
|
||||
|
||||
int Dictionary::FindInt(CSZ name, int def) const
|
||||
int Dictionary::FindInt(CSZ key, int def) const
|
||||
{
|
||||
VERUS_IF_FOUND_IN(TStoreValues::TMap, TStoreValues::_map, name, it)
|
||||
VERUS_IF_FOUND_IN(TStoreValues::TMap, TStoreValues::_map, key, it)
|
||||
return it->second._i;
|
||||
if (_pParent)
|
||||
return _pParent->FindInt(name, def);
|
||||
return _pParent->FindInt(key, def);
|
||||
return def;
|
||||
}
|
||||
|
||||
float Dictionary::FindFloat(CSZ name, float def) const
|
||||
float Dictionary::FindFloat(CSZ key, float def) const
|
||||
{
|
||||
VERUS_IF_FOUND_IN(TStoreValues::TMap, TStoreValues::_map, name, it)
|
||||
VERUS_IF_FOUND_IN(TStoreValues::TMap, TStoreValues::_map, key, it)
|
||||
return it->second._f;
|
||||
if (_pParent)
|
||||
return _pParent->FindFloat(name, def);
|
||||
return _pParent->FindFloat(key, def);
|
||||
return def;
|
||||
}
|
||||
|
||||
|
@ -123,15 +123,15 @@ void Dictionary::Serialize(RStream stream)
|
|||
void Dictionary::Deserialize(RStream stream)
|
||||
{
|
||||
DeleteAll();
|
||||
char name[Stream::s_bufferSize];
|
||||
char key[Stream::s_bufferSize];
|
||||
char value[Stream::s_bufferSize];
|
||||
BYTE count;
|
||||
stream >> count;
|
||||
VERUS_FOR(i, count)
|
||||
{
|
||||
stream.ReadString(name);
|
||||
stream.ReadString(key);
|
||||
stream.ReadString(value);
|
||||
Insert(name, value);
|
||||
Insert(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,14 +32,14 @@ namespace verus
|
|||
|
||||
void LinkParent(Dictionary* p);
|
||||
|
||||
void Insert(CSZ name, CSZ value);
|
||||
void Delete(CSZ name);
|
||||
void Insert(CSZ key, CSZ value);
|
||||
void Delete(CSZ key);
|
||||
void DeleteAll();
|
||||
|
||||
CSZ Find(CSZ name, CSZ def = nullptr) const;
|
||||
RcString FindSafe(CSZ name) const;
|
||||
int FindInt(CSZ name, int def = 0) const;
|
||||
float FindFloat(CSZ name, float def = 0) const;
|
||||
CSZ Find(CSZ key, CSZ def = nullptr) const;
|
||||
RcString FindSafe(CSZ key) const;
|
||||
int FindInt(CSZ key, int def = 0) const;
|
||||
float FindFloat(CSZ key, float def = 0) const;
|
||||
|
||||
int GetCount() const;
|
||||
|
||||
|
|
|
@ -32,12 +32,12 @@ void FileSystem::ReadPakHeader(RFile file, UINT32& magic, INT64& entriesOffset,
|
|||
{
|
||||
file >> magic;
|
||||
if (magic != 'KAP2')
|
||||
throw VERUS_RUNTIME_ERROR << "ReadPakHeader(), Invalid magic number in PAK";
|
||||
throw VERUS_RUNTIME_ERROR << "ReadPakHeader(); Invalid magic number in PAK";
|
||||
|
||||
file >> entriesOffset;
|
||||
file >> entriesSize;
|
||||
if (entriesSize % s_entrySize)
|
||||
throw VERUS_RUNTIME_ERROR << "ReadPakHeader(), Invalid size of entries in PAK";
|
||||
throw VERUS_RUNTIME_ERROR << "ReadPakHeader(); Invalid size of entries in PAK";
|
||||
}
|
||||
|
||||
void FileSystem::PreloadCache(CSZ pak, CSZ types[])
|
||||
|
@ -97,7 +97,7 @@ void FileSystem::PreloadCache(CSZ pak, CSZ types[])
|
|||
uLongf destLen = Utils::Cast32(size);
|
||||
const int ret = uncompress(vData.data(), &destLen, vZip.data(), Utils::Cast32(vZip.size()));
|
||||
if (ret != Z_OK)
|
||||
throw VERUS_RUNTIME_ERROR << "uncompress(), " << ret;
|
||||
throw VERUS_RUNTIME_ERROR << "uncompress(); " << ret;
|
||||
|
||||
_cacheSize += vData.size();
|
||||
String key("[");
|
||||
|
@ -201,7 +201,7 @@ void FileSystem::LoadResourceFromFile(CSZ url, Vector<BYTE>& vData, RcLoadDesc d
|
|||
}
|
||||
}
|
||||
else if (desc._mandatory)
|
||||
throw VERUS_RUNTIME_ERROR << "LoadResourceFromFile(), File not found: " << url << " (" << strUrl << ")";
|
||||
throw VERUS_RUNTIME_ERROR << "LoadResourceFromFile(); File not found: " << url << " (" << strUrl << ")";
|
||||
}
|
||||
|
||||
void FileSystem::LoadResourceFromCache(CSZ url, Vector<BYTE>& vData, bool mandatory)
|
||||
|
@ -213,7 +213,7 @@ void FileSystem::LoadResourceFromCache(CSZ url, Vector<BYTE>& vData, bool mandat
|
|||
if (it != _mapCache.end())
|
||||
vData = it->second;
|
||||
else if (mandatory)
|
||||
throw VERUS_RUNTIME_ERROR << "LoadResourceFromCache(), File not found in cache: " << url;
|
||||
throw VERUS_RUNTIME_ERROR << "LoadResourceFromCache(); File not found in cache: " << url;
|
||||
}
|
||||
|
||||
void FileSystem::LoadResourceFromPAK(CSZ url, Vector<BYTE>& vData, RcLoadDesc desc, RFile file, CSZ pakEntry)
|
||||
|
@ -268,7 +268,7 @@ void FileSystem::LoadResourceFromPAK(CSZ url, Vector<BYTE>& vData, RcLoadDesc de
|
|||
DDSHeader header;
|
||||
file >> header;
|
||||
if (!header.Validate())
|
||||
throw VERUS_RUNTIME_ERROR << "LoadResourceFromPAK(), Invalid DDS header: " << url;
|
||||
throw VERUS_RUNTIME_ERROR << "LoadResourceFromPAK(); Invalid DDS header: " << url;
|
||||
DDSHeaderDXT10 header10;
|
||||
if (header.IsDXT10())
|
||||
{
|
||||
|
@ -279,7 +279,7 @@ void FileSystem::LoadResourceFromPAK(CSZ url, Vector<BYTE>& vData, RcLoadDesc de
|
|||
const int skipPartCount = header.SkipParts(desc._texturePart);
|
||||
|
||||
if (partCount > maxParts)
|
||||
throw VERUS_RUNTIME_ERROR << "LoadResourceFromPAK(), Too many parts in PAK";
|
||||
throw VERUS_RUNTIME_ERROR << "LoadResourceFromPAK(); Too many parts in PAK";
|
||||
|
||||
INT64 totalSize = headerSize;
|
||||
VERUS_FOR(part, partCount)
|
||||
|
@ -309,7 +309,7 @@ void FileSystem::LoadResourceFromPAK(CSZ url, Vector<BYTE>& vData, RcLoadDesc de
|
|||
file.Seek(pakDataOffset + partOffset, SEEK_SET);
|
||||
file >> size;
|
||||
if (size != partSize)
|
||||
throw VERUS_RUNTIME_ERROR << "LoadResourceFromPAK(), Invalid size in PAK";
|
||||
throw VERUS_RUNTIME_ERROR << "LoadResourceFromPAK(); Invalid size in PAK";
|
||||
vCip.resize(partZipSize - sizeof(INT64));
|
||||
vZip.resize(partZipSize - sizeof(INT64));
|
||||
file.Read(vCip.data(), vCip.size());
|
||||
|
@ -317,7 +317,7 @@ void FileSystem::LoadResourceFromPAK(CSZ url, Vector<BYTE>& vData, RcLoadDesc de
|
|||
uLongf destLen = Utils::Cast32(size);
|
||||
const int ret = uncompress(vData.data() + dataPos, &destLen, vZip.data(), Utils::Cast32(vZip.size()));
|
||||
if (ret != Z_OK)
|
||||
throw VERUS_RUNTIME_ERROR << "uncompress(), " << ret;
|
||||
throw VERUS_RUNTIME_ERROR << "uncompress(); " << ret;
|
||||
}
|
||||
dataPos += size;
|
||||
}
|
||||
|
@ -335,7 +335,7 @@ void FileSystem::LoadResourceFromPAK(CSZ url, Vector<BYTE>& vData, RcLoadDesc de
|
|||
uLongf destLen = Utils::Cast32(size);
|
||||
const int ret = uncompress(vData.data(), &destLen, vZip.data(), Utils::Cast32(vZip.size()));
|
||||
if (ret != Z_OK)
|
||||
throw VERUS_RUNTIME_ERROR << "uncompress(), " << ret;
|
||||
throw VERUS_RUNTIME_ERROR << "uncompress(); " << ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -345,7 +345,7 @@ void FileSystem::LoadTextureParts(RFile file, CSZ url, int texturePart, Vector<B
|
|||
DDSHeader header;
|
||||
file >> header;
|
||||
if (!header.Validate())
|
||||
throw VERUS_RUNTIME_ERROR << "LoadTextureParts(), Invalid DDS header: " << url;
|
||||
throw VERUS_RUNTIME_ERROR << "LoadTextureParts(); Invalid DDS header: " << url;
|
||||
DDSHeaderDXT10 header10;
|
||||
if (header.IsDXT10())
|
||||
{
|
||||
|
@ -513,14 +513,14 @@ void FileSystem::SaveImage(CSZ pathname, const UINT32* p, int w, int h, ImageFor
|
|||
file.Close();
|
||||
}
|
||||
else
|
||||
throw VERUS_RUNTIME_ERROR << "SaveImage(), Open()";
|
||||
throw VERUS_RUNTIME_ERROR << "SaveImage(); Open()";
|
||||
}
|
||||
|
||||
void FileSystem::SaveDDS(CSZ pathname, const UINT32* p, int w, int h, int d)
|
||||
{
|
||||
IO::File file;
|
||||
if (!file.Open(pathname, "wb"))
|
||||
throw VERUS_RUNTIME_ERROR << "SaveDDS(), Open()";
|
||||
throw VERUS_RUNTIME_ERROR << "SaveDDS(); Open()";
|
||||
|
||||
DDSHeader header;
|
||||
header._flags |= DDSHeader::Flags::linearSize;
|
||||
|
|
|
@ -39,7 +39,7 @@ void Json::Load(bool fromCache)
|
|||
else
|
||||
{
|
||||
StringStream ss;
|
||||
ss << "Load() url=" << _pathname;
|
||||
ss << "Load(); url=" << _pathname;
|
||||
VERUS_LOG_INFO(_C(ss.str()));
|
||||
|
||||
const size_t pakPos = FileSystem::FindPosForPAK(_C(_pathname));
|
||||
|
@ -63,7 +63,7 @@ void Json::Load(bool fromCache)
|
|||
void Json::Save()
|
||||
{
|
||||
StringStream ss;
|
||||
ss << "Save() url=" << _pathname;
|
||||
ss << "Save(); url=" << _pathname;
|
||||
File file;
|
||||
if (file.Open(_C(_pathname), "w"))
|
||||
{
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace verus
|
|||
{
|
||||
const size_t len = strlen(sz);
|
||||
if (len > UCHAR_MAX)
|
||||
throw verus::D::RuntimeError(std::this_thread::get_id(), "Stream.h", __LINE__) << "WriteString(), Invalid string length";
|
||||
throw verus::D::RuntimeError(std::this_thread::get_id(), "Stream.h", __LINE__) << "WriteString(); Invalid string length";
|
||||
(*this) << static_cast<BYTE>(len);
|
||||
const INT64 ret = Write(sz, len);
|
||||
return ret + 1;
|
||||
|
|
|
@ -36,12 +36,12 @@ void Xml::Load(bool fromCache)
|
|||
FileSystem::I().LoadResourceFromCache(_C(_pathname), _vData);
|
||||
const pugi::xml_parse_result result = _doc.load_buffer_inplace(_vData.data(), _vData.size());
|
||||
if (!result)
|
||||
throw VERUS_RECOVERABLE << "load_buffer_inplace(), " << result.description();
|
||||
throw VERUS_RECOVERABLE << "load_buffer_inplace(); " << result.description();
|
||||
}
|
||||
else
|
||||
{
|
||||
StringStream ss;
|
||||
ss << "Load() url=" << _pathname;
|
||||
ss << "Load(); url=" << _pathname;
|
||||
VERUS_LOG_INFO(_C(ss.str()));
|
||||
|
||||
const size_t pakPos = FileSystem::FindPosForPAK(_C(_pathname));
|
||||
|
@ -50,7 +50,7 @@ void Xml::Load(bool fromCache)
|
|||
FileSystem::LoadResource(_C(_pathname), _vData, FileSystem::LoadDesc(true));
|
||||
const pugi::xml_parse_result result = _doc.load_buffer_inplace(_vData.data(), _vData.size());
|
||||
if (!result)
|
||||
throw VERUS_RECOVERABLE << "load_buffer_inplace(), " << result.description();
|
||||
throw VERUS_RECOVERABLE << "load_buffer_inplace(); " << result.description();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -60,7 +60,7 @@ void Xml::Load(bool fromCache)
|
|||
file.ReadAll(_vData, true);
|
||||
const pugi::xml_parse_result result = _doc.load_buffer_inplace(_vData.data(), _vData.size());
|
||||
if (!result)
|
||||
throw VERUS_RECOVERABLE << "load_buffer_inplace(), " << result.description();
|
||||
throw VERUS_RECOVERABLE << "load_buffer_inplace(); " << result.description();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ void Xml::Load(bool fromCache)
|
|||
void Xml::Save()
|
||||
{
|
||||
StringStream ss;
|
||||
ss << "Save() url=" << _pathname;
|
||||
ss << "Save(); url=" << _pathname;
|
||||
File file;
|
||||
if (file.Open(_C(_pathname), "w"))
|
||||
{
|
||||
|
|
|
@ -5,10 +5,10 @@ namespace verus
|
|||
{
|
||||
void Make_Input()
|
||||
{
|
||||
Input::KeyMapper::Make();
|
||||
Input::InputManager::Make();
|
||||
}
|
||||
void Free_Input()
|
||||
{
|
||||
Input::KeyMapper::Free();
|
||||
Input::InputManager::Free();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2021, Dmitry Maluev (dmaluev@gmail.com). All rights reserved.
|
||||
#pragma once
|
||||
|
||||
#include "KeyMapper.h"
|
||||
#include "InputManager.h"
|
||||
#include "DragController.h"
|
||||
|
||||
namespace verus
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
using namespace verus;
|
||||
using namespace verus::Input;
|
||||
|
||||
KeyMapper::KeyMapper()
|
||||
InputManager::InputManager()
|
||||
{
|
||||
VERUS_ZERO_MEM(_kbStatePressed);
|
||||
VERUS_ZERO_MEM(_kbStateDownEvent);
|
||||
|
@ -19,15 +19,17 @@ KeyMapper::KeyMapper()
|
|||
VERUS_ZERO_MEM(_joyStateUpEvent);
|
||||
}
|
||||
|
||||
KeyMapper::~KeyMapper()
|
||||
InputManager::~InputManager()
|
||||
{
|
||||
Done();
|
||||
}
|
||||
|
||||
void KeyMapper::Init()
|
||||
void InputManager::Init()
|
||||
{
|
||||
VERUS_INIT();
|
||||
|
||||
_vInputFocusStack.reserve(16);
|
||||
|
||||
const int count = SDL_NumJoysticks();
|
||||
_vJoysticks.reserve(count);
|
||||
VERUS_FOR(i, count)
|
||||
|
@ -38,36 +40,28 @@ void KeyMapper::Init()
|
|||
}
|
||||
}
|
||||
|
||||
void KeyMapper::Done()
|
||||
void InputManager::Done()
|
||||
{
|
||||
VERUS_FOREACH_CONST(Vector<SDL_Joystick*>, _vJoysticks, it)
|
||||
SDL_JoystickClose(*it);
|
||||
_vJoysticks.clear();
|
||||
|
||||
VERUS_DONE(KeyMapper);
|
||||
VERUS_DONE(InputManager);
|
||||
}
|
||||
|
||||
bool KeyMapper::HandleSdlEvent(SDL_Event& event)
|
||||
bool InputManager::HandleEvent(SDL_Event& event)
|
||||
{
|
||||
VERUS_RT_ASSERT(IsInitialized());
|
||||
VERUS_QREF_CONST_SETTINGS;
|
||||
|
||||
static bool firstTime = true;
|
||||
|
||||
switch (event.type)
|
||||
{
|
||||
// Keyboard:
|
||||
// KEYBOARD:
|
||||
case SDL_KEYDOWN:
|
||||
{
|
||||
if (ImGui::GetIO().WantCaptureKeyboard)
|
||||
return false;
|
||||
#if defined(_DEBUG) || defined(VERUS_RELEASE_DEBUG)
|
||||
if (SDL_SCANCODE_KP_ENTER == event.key.keysym.scancode)
|
||||
{
|
||||
const SDL_bool rel = SDL_GetRelativeMouseMode();
|
||||
SDL_SetRelativeMouseMode(rel ? SDL_FALSE : SDL_TRUE);
|
||||
}
|
||||
#endif
|
||||
SwitchRelativeMouseMode(event.key.keysym.scancode);
|
||||
OnKeyDown(event.key.keysym.scancode);
|
||||
}
|
||||
break;
|
||||
|
@ -84,17 +78,18 @@ bool KeyMapper::HandleSdlEvent(SDL_Event& event)
|
|||
return false;
|
||||
wchar_t wide[4];
|
||||
Str::Utf8ToWide(event.text.text, wide, 4);
|
||||
OnChar(wide[0]);
|
||||
OnTextInput(wide[0]);
|
||||
}
|
||||
break;
|
||||
|
||||
// Mouse:
|
||||
// MOUSE:
|
||||
case SDL_MOUSEMOTION:
|
||||
{
|
||||
if (!firstTime)
|
||||
OnMouseMove(event.motion.xrel, event.motion.yrel);
|
||||
else
|
||||
firstTime = false;
|
||||
OnMouseMove(
|
||||
event.motion.xrel,
|
||||
event.motion.yrel,
|
||||
event.motion.x,
|
||||
event.motion.y);
|
||||
}
|
||||
break;
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
|
@ -138,7 +133,7 @@ bool KeyMapper::HandleSdlEvent(SDL_Event& event)
|
|||
}
|
||||
break;
|
||||
|
||||
// Joystick:
|
||||
// JOYSTICK:
|
||||
case SDL_JOYAXISMOTION:
|
||||
{
|
||||
OnJoyAxis(event.jaxis.axis, event.jaxis.value);
|
||||
|
@ -161,81 +156,113 @@ bool KeyMapper::HandleSdlEvent(SDL_Event& event)
|
|||
return true;
|
||||
}
|
||||
|
||||
void KeyMapper::Load(Action* pAction)
|
||||
void InputManager::HandleInput()
|
||||
{
|
||||
for (auto p : _vInputFocusStack)
|
||||
{
|
||||
p->HandleInput();
|
||||
if (p->VetoInputFocus())
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int InputManager::GainFocus(PInputFocus p)
|
||||
{
|
||||
auto it = std::find(_vInputFocusStack.begin(), _vInputFocusStack.end(), p);
|
||||
if (it != _vInputFocusStack.end())
|
||||
std::rotate(it, it + 1, _vInputFocusStack.end());
|
||||
else
|
||||
_vInputFocusStack.push_back(p);
|
||||
return static_cast<int>(_vInputFocusStack.size()) - 1;
|
||||
}
|
||||
|
||||
int InputManager::LoseFocus(PInputFocus p)
|
||||
{
|
||||
auto it = std::find(_vInputFocusStack.begin(), _vInputFocusStack.end(), p);
|
||||
if (it != _vInputFocusStack.end())
|
||||
{
|
||||
const int index = Utils::Cast32(it - _vInputFocusStack.begin());
|
||||
_vInputFocusStack.erase(std::remove(_vInputFocusStack.begin(), _vInputFocusStack.end(), p), _vInputFocusStack.end());
|
||||
return index;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void InputManager::Load(Action* pAction)
|
||||
{
|
||||
StringStream ss;
|
||||
ss << _C(Utils::I().GetWritablePath()) << "Keys.xml";
|
||||
IO::Xml xml(_C(ss.str()));
|
||||
}
|
||||
|
||||
bool KeyMapper::IsKeyPressed(int id) const
|
||||
bool InputManager::IsKeyPressed(int id) const
|
||||
{
|
||||
id = Math::Clamp(id, 0, VERUS_INPUT_MAX_KB - 1);
|
||||
return _kbStatePressed[id] || TranslateJoyPress(id, false);
|
||||
}
|
||||
|
||||
bool KeyMapper::IsKeyDownEvent(int id) const
|
||||
bool InputManager::IsKeyDownEvent(int id) const
|
||||
{
|
||||
id = Math::Clamp(id, 0, VERUS_INPUT_MAX_KB - 1);
|
||||
return _kbStateDownEvent[id];
|
||||
}
|
||||
|
||||
bool KeyMapper::IsKeyUpEvent(int id) const
|
||||
bool InputManager::IsKeyUpEvent(int id) const
|
||||
{
|
||||
id = Math::Clamp(id, 0, VERUS_INPUT_MAX_KB - 1);
|
||||
return _kbStateUpEvent[id];
|
||||
}
|
||||
|
||||
bool KeyMapper::IsMousePressed(int id) const
|
||||
bool InputManager::IsMousePressed(int id) const
|
||||
{
|
||||
id = Math::Clamp(id, 0, VERUS_INPUT_MAX_MOUSE - 1);
|
||||
return _mouseStatePressed[id] || TranslateJoyPress(id, true);
|
||||
}
|
||||
|
||||
bool KeyMapper::IsMouseDownEvent(int id) const
|
||||
bool InputManager::IsMouseDownEvent(int id) const
|
||||
{
|
||||
id = Math::Clamp(id, 0, VERUS_INPUT_MAX_MOUSE - 1);
|
||||
return _mouseStateDownEvent[id];
|
||||
}
|
||||
|
||||
bool KeyMapper::IsMouseUpEvent(int id) const
|
||||
bool InputManager::IsMouseUpEvent(int id) const
|
||||
{
|
||||
id = Math::Clamp(id, 0, VERUS_INPUT_MAX_MOUSE - 1);
|
||||
return _mouseStateUpEvent[id];
|
||||
}
|
||||
|
||||
bool KeyMapper::IsMouseDoubleClick(int id) const
|
||||
bool InputManager::IsMouseDoubleClick(int id) const
|
||||
{
|
||||
id = Math::Clamp(id, 0, VERUS_INPUT_MAX_MOUSE - 1);
|
||||
return _mouseStateDoubleClick[id];
|
||||
}
|
||||
|
||||
bool KeyMapper::IsActionPressed(int actionID) const
|
||||
bool InputManager::IsActionPressed(int actionID) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KeyMapper::IsActionDownEvent(int actionID) const
|
||||
bool InputManager::IsActionDownEvent(int actionID) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KeyMapper::IsActionUpEvent(int actionID) const
|
||||
bool InputManager::IsActionUpEvent(int actionID) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
float KeyMapper::GetJoyAxisState(int id) const
|
||||
float InputManager::GetJoyAxisState(int id) const
|
||||
{
|
||||
id = Math::Clamp(id, 0, JOY_AXIS_MAX - 1);
|
||||
return _joyStateAxis[id];
|
||||
}
|
||||
|
||||
void KeyMapper::BuildLookup()
|
||||
void InputManager::BuildLookup()
|
||||
{
|
||||
}
|
||||
|
||||
void KeyMapper::ResetClickState()
|
||||
void InputManager::ResetInputState()
|
||||
{
|
||||
VERUS_ZERO_MEM(_kbStateDownEvent);
|
||||
VERUS_ZERO_MEM(_kbStateUpEvent);
|
||||
|
@ -246,55 +273,83 @@ void KeyMapper::ResetClickState()
|
|||
VERUS_ZERO_MEM(_joyStateUpEvent);
|
||||
}
|
||||
|
||||
void KeyMapper::OnKeyDown(int id)
|
||||
float InputManager::GetMouseScale()
|
||||
{
|
||||
VERUS_QREF_CONST_SETTINGS;
|
||||
const float rad = (VERUS_2PI / 360.f) / 3.f; // 3 pixels = 1 degree.
|
||||
return rad * settings._inputMouseSensitivity;
|
||||
}
|
||||
|
||||
void InputManager::SwitchRelativeMouseMode(int scancode)
|
||||
{
|
||||
#if defined(_DEBUG) || defined(VERUS_RELEASE_DEBUG)
|
||||
if (SDL_SCANCODE_KP_ENTER == scancode)
|
||||
{
|
||||
const SDL_bool rel = SDL_GetRelativeMouseMode();
|
||||
SDL_SetRelativeMouseMode(rel ? SDL_FALSE : SDL_TRUE);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void InputManager::OnKeyDown(int id)
|
||||
{
|
||||
id = Math::Clamp(id, 0, VERUS_INPUT_MAX_KB - 1);
|
||||
_kbStatePressed[id] = true;
|
||||
_kbStateDownEvent[id] = true;
|
||||
if (_pKeyMapperDelegate)
|
||||
_pKeyMapperDelegate->KeyMapper_OnKey(id);
|
||||
}
|
||||
|
||||
void KeyMapper::OnKeyUp(int id)
|
||||
void InputManager::OnKeyUp(int id)
|
||||
{
|
||||
id = Math::Clamp(id, 0, VERUS_INPUT_MAX_KB - 1);
|
||||
_kbStatePressed[id] = false;
|
||||
_kbStateUpEvent[id] = true;
|
||||
}
|
||||
|
||||
void KeyMapper::OnChar(wchar_t c)
|
||||
void InputManager::OnTextInput(wchar_t c)
|
||||
{
|
||||
if (c && _pKeyMapperDelegate)
|
||||
_pKeyMapperDelegate->KeyMapper_OnChar(c);
|
||||
for (auto p : _vInputFocusStack)
|
||||
{
|
||||
p->OnTextInput(c);
|
||||
if (p->VetoInputFocus())
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void KeyMapper::OnMouseMove(int x, int y)
|
||||
void InputManager::OnMouseMove(int dx, int dy, int x, int y)
|
||||
{
|
||||
if (_pKeyMapperDelegate)
|
||||
_pKeyMapperDelegate->KeyMapper_OnMouseMove(x, y);
|
||||
const float scale = GetMouseScale();
|
||||
const float fdx = dx * scale;
|
||||
const float fdy = dy * scale;
|
||||
for (auto p : _vInputFocusStack)
|
||||
{
|
||||
p->OnMouseMove(dx, dy, x, y);
|
||||
p->OnMouseMove(fdx, fdy);
|
||||
if (p->VetoInputFocus())
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void KeyMapper::OnMouseDown(int id)
|
||||
void InputManager::OnMouseDown(int id)
|
||||
{
|
||||
id = Math::Clamp(id, 0, VERUS_INPUT_MAX_MOUSE - 1);
|
||||
_mouseStatePressed[id] = true;
|
||||
_mouseStateDownEvent[id] = true;
|
||||
}
|
||||
|
||||
void KeyMapper::OnMouseUp(int id)
|
||||
void InputManager::OnMouseUp(int id)
|
||||
{
|
||||
id = Math::Clamp(id, 0, VERUS_INPUT_MAX_MOUSE - 1);
|
||||
_mouseStatePressed[id] = false;
|
||||
_mouseStateUpEvent[id] = true;
|
||||
}
|
||||
|
||||
void KeyMapper::OnMouseDoubleClick(int id)
|
||||
void InputManager::OnMouseDoubleClick(int id)
|
||||
{
|
||||
id = Math::Clamp(id, 0, VERUS_INPUT_MAX_MOUSE - 1);
|
||||
_mouseStateDoubleClick[id] = true;
|
||||
}
|
||||
|
||||
void KeyMapper::OnJoyAxis(int id, int value)
|
||||
void InputManager::OnJoyAxis(int id, int value)
|
||||
{
|
||||
id = Math::Clamp(id, 0, JOY_AXIS_MAX - 1);
|
||||
const float amount = value * (1.f / SHRT_MAX);
|
||||
|
@ -313,7 +368,7 @@ void KeyMapper::OnJoyAxis(int id, int value)
|
|||
_joyStateAxis[id] = fixedAmount;
|
||||
}
|
||||
|
||||
void KeyMapper::OnJoyDown(int id)
|
||||
void InputManager::OnJoyDown(int id)
|
||||
{
|
||||
id = Math::Clamp(id, 0, JOY_BUTTON_MAX - 1);
|
||||
_joyStatePressed[id] = true;
|
||||
|
@ -321,7 +376,7 @@ void KeyMapper::OnJoyDown(int id)
|
|||
TranslateJoy(id, false);
|
||||
}
|
||||
|
||||
void KeyMapper::OnJoyUp(int id)
|
||||
void InputManager::OnJoyUp(int id)
|
||||
{
|
||||
id = Math::Clamp(id, 0, JOY_BUTTON_MAX - 1);
|
||||
_joyStatePressed[id] = false;
|
||||
|
@ -329,7 +384,7 @@ void KeyMapper::OnJoyUp(int id)
|
|||
TranslateJoy(id, true);
|
||||
}
|
||||
|
||||
void KeyMapper::TranslateJoy(int id, bool up)
|
||||
void InputManager::TranslateJoy(int id, bool up)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
|
@ -371,7 +426,7 @@ void KeyMapper::TranslateJoy(int id, bool up)
|
|||
}
|
||||
}
|
||||
|
||||
bool KeyMapper::TranslateJoyPress(int id, bool mouse) const
|
||||
bool InputManager::TranslateJoyPress(int id, bool mouse) const
|
||||
{
|
||||
if (mouse)
|
||||
{
|
|
@ -11,13 +11,15 @@ namespace verus
|
|||
{
|
||||
namespace Input
|
||||
{
|
||||
struct KeyMapperDelegate
|
||||
struct InputFocus
|
||||
{
|
||||
virtual void KeyMapper_OnMouseMove(int x, int y) = 0;
|
||||
virtual void KeyMapper_OnKey(int scancode) = 0;
|
||||
virtual void KeyMapper_OnChar(wchar_t c) = 0;
|
||||
virtual bool VetoInputFocus() { return false; }
|
||||
virtual void HandleInput() {}
|
||||
virtual void OnMouseMove(int dx, int dy, int x, int y) {}
|
||||
virtual void OnMouseMove(float dx, float dy) {}
|
||||
virtual void OnTextInput(wchar_t c) {}
|
||||
};
|
||||
VERUS_TYPEDEFS(KeyMapperDelegate);
|
||||
VERUS_TYPEDEFS(InputFocus);
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -50,7 +52,7 @@ namespace verus
|
|||
JOY_BUTTON_MAX
|
||||
};
|
||||
|
||||
class KeyMapper : public Singleton<KeyMapper>, public Object
|
||||
class InputManager : public Singleton<InputManager>, public Object
|
||||
{
|
||||
struct Action
|
||||
{
|
||||
|
@ -62,6 +64,7 @@ namespace verus
|
|||
|
||||
typedef Map<int, int> TMapLookup;
|
||||
|
||||
Vector<PInputFocus> _vInputFocusStack;
|
||||
Vector<Action> _mapAction;
|
||||
TMapLookup _mapLookupByKey;
|
||||
TMapLookup _mapLookupByAction;
|
||||
|
@ -72,7 +75,6 @@ namespace verus
|
|||
bool _mouseStateDownEvent[VERUS_INPUT_MAX_MOUSE];
|
||||
bool _mouseStateUpEvent[VERUS_INPUT_MAX_MOUSE];
|
||||
bool _mouseStateDoubleClick[VERUS_INPUT_MAX_MOUSE];
|
||||
PKeyMapperDelegate _pKeyMapperDelegate = nullptr;
|
||||
Vector<SDL_Joystick*> _vJoysticks;
|
||||
float _joyStateAxis[JOY_AXIS_MAX];
|
||||
bool _joyStatePressed[JOY_BUTTON_MAX];
|
||||
|
@ -80,13 +82,17 @@ namespace verus
|
|||
bool _joyStateUpEvent[JOY_BUTTON_MAX];
|
||||
|
||||
public:
|
||||
KeyMapper();
|
||||
~KeyMapper();
|
||||
InputManager();
|
||||
~InputManager();
|
||||
|
||||
void Init();
|
||||
void Done();
|
||||
|
||||
bool HandleSdlEvent(SDL_Event& event);
|
||||
bool HandleEvent(SDL_Event& event);
|
||||
void HandleInput();
|
||||
|
||||
int GainFocus(PInputFocus p);
|
||||
int LoseFocus(PInputFocus p);
|
||||
|
||||
void Load(Action* pAction);
|
||||
|
||||
|
@ -107,18 +113,20 @@ namespace verus
|
|||
|
||||
void BuildLookup();
|
||||
|
||||
void ResetClickState();
|
||||
void ResetInputState();
|
||||
|
||||
PKeyMapperDelegate SetDelegate(PKeyMapperDelegate p) { return Utils::Swap(_pKeyMapperDelegate, p); }
|
||||
static float GetMouseScale();
|
||||
|
||||
static CSZ GetSingletonFailMessage() { return "Make_Input(); // FAIL.\r\n"; }
|
||||
|
||||
private:
|
||||
void SwitchRelativeMouseMode(int scancode);
|
||||
|
||||
void OnKeyDown(int id);
|
||||
void OnKeyUp(int id);
|
||||
void OnChar(wchar_t c);
|
||||
void OnTextInput(wchar_t c);
|
||||
|
||||
void OnMouseMove(int x, int y);
|
||||
void OnMouseMove(int dx, int dy, int x, int y);
|
||||
void OnMouseDown(int id);
|
||||
void OnMouseUp(int id);
|
||||
void OnMouseDoubleClick(int id);
|
||||
|
@ -129,6 +137,6 @@ namespace verus
|
|||
void TranslateJoy(int id, bool up);
|
||||
bool TranslateJoyPress(int id, bool mouse) const;
|
||||
};
|
||||
VERUS_TYPEDEFS(KeyMapper);
|
||||
VERUS_TYPEDEFS(InputManager);
|
||||
}
|
||||
}
|
|
@ -83,7 +83,7 @@ void Addr::FromString(CSZ addr)
|
|||
const int ret = getaddrinfo(addr, 0, &hints, &raii.pAddrInfo);
|
||||
if (ret)
|
||||
{
|
||||
throw VERUS_RECOVERABLE << "getaddrinfo(), " << ret;
|
||||
throw VERUS_RECOVERABLE << "getaddrinfo(); " << ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -92,27 +92,27 @@ void Socket::Listen(int port)
|
|||
char porttext[16];
|
||||
sprintf_s(porttext, "%d", port);
|
||||
if (ret = getaddrinfo(0, porttext, &hints, &raii.pAddrInfo))
|
||||
throw VERUS_RECOVERABLE << "getaddrinfo(), " << ret;
|
||||
throw VERUS_RECOVERABLE << "getaddrinfo(); " << ret;
|
||||
|
||||
_socket = socket(
|
||||
raii.pAddrInfo->ai_family,
|
||||
raii.pAddrInfo->ai_socktype,
|
||||
raii.pAddrInfo->ai_protocol);
|
||||
if (INVALID_SOCKET == _socket)
|
||||
throw VERUS_RECOVERABLE << "socket(), " << WSAGetLastError();
|
||||
throw VERUS_RECOVERABLE << "socket(); " << WSAGetLastError();
|
||||
|
||||
if (bind(_socket,
|
||||
raii.pAddrInfo->ai_addr,
|
||||
Utils::Cast32(raii.pAddrInfo->ai_addrlen)))
|
||||
{
|
||||
closesocket(_socket);
|
||||
throw VERUS_RECOVERABLE << "bind(), " << WSAGetLastError();
|
||||
throw VERUS_RECOVERABLE << "bind(); " << WSAGetLastError();
|
||||
}
|
||||
|
||||
if (listen(_socket, SOMAXCONN))
|
||||
{
|
||||
closesocket(_socket);
|
||||
throw VERUS_RECOVERABLE << "listen(), " << WSAGetLastError();
|
||||
throw VERUS_RECOVERABLE << "listen(); " << WSAGetLastError();
|
||||
}
|
||||
|
||||
_vClients.resize(_maxClients);
|
||||
|
@ -132,11 +132,11 @@ void Socket::Connect(RcAddr addr)
|
|||
else
|
||||
{
|
||||
closesocket(_socket);
|
||||
throw VERUS_RECOVERABLE << "connect(), " << WSAGetLastError();
|
||||
throw VERUS_RECOVERABLE << "connect(); " << WSAGetLastError();
|
||||
}
|
||||
}
|
||||
else
|
||||
throw VERUS_RECOVERABLE << "socket(), " << WSAGetLastError();
|
||||
throw VERUS_RECOVERABLE << "socket(); " << WSAGetLastError();
|
||||
}
|
||||
|
||||
void Socket::Udp(int port)
|
||||
|
@ -152,18 +152,18 @@ void Socket::Udp(int port)
|
|||
if (bind(_socket, reinterpret_cast<const sockaddr*>(&sa), sizeof(sa)) < 0)
|
||||
{
|
||||
closesocket(_socket);
|
||||
throw VERUS_RECOVERABLE << "bind(), " << WSAGetLastError();
|
||||
throw VERUS_RECOVERABLE << "bind(); " << WSAGetLastError();
|
||||
}
|
||||
// Non-blocking mode:
|
||||
u_long mode = 1;
|
||||
if (ioctlsocket(_socket, FIONBIO, &mode))
|
||||
{
|
||||
closesocket(_socket);
|
||||
throw VERUS_RECOVERABLE << "ioctlsocket(FIONBIO), " << WSAGetLastError();
|
||||
throw VERUS_RECOVERABLE << "ioctlsocket(FIONBIO); " << WSAGetLastError();
|
||||
}
|
||||
}
|
||||
else
|
||||
throw VERUS_RECOVERABLE << "socket(), " << WSAGetLastError();
|
||||
throw VERUS_RECOVERABLE << "socket(); " << WSAGetLastError();
|
||||
}
|
||||
|
||||
void Socket::Close()
|
||||
|
|
|
@ -59,10 +59,10 @@ void BaseMesh::Load(RcBlob blob)
|
|||
}
|
||||
else
|
||||
{
|
||||
throw VERUS_RECOVERABLE << "Load(), invalid magic number";
|
||||
throw VERUS_RECOVERABLE << "Load(); Invalid magic number";
|
||||
}
|
||||
}
|
||||
VERUS_LOG_WARN("Load(), Old X3D version");
|
||||
VERUS_LOG_WARN("Load(); Old X3D version");
|
||||
}
|
||||
|
||||
void BaseMesh::LoadX3D3(RcBlob blob)
|
||||
|
|
|
@ -95,7 +95,7 @@ void Forest::Init(PTerrain pTerrain, CSZ url)
|
|||
pugi::xml_document doc;
|
||||
const pugi::xml_parse_result result = doc.load_buffer_inplace(vData.data(), vData.size());
|
||||
if (!result)
|
||||
throw VERUS_RECOVERABLE << "load_buffer_inplace(), " << result.description();
|
||||
throw VERUS_RECOVERABLE << "load_buffer_inplace(); " << result.description();
|
||||
pugi::xml_node root = doc.first_child();
|
||||
|
||||
for (auto layerNode : root.children("layer"))
|
||||
|
|
|
@ -71,7 +71,7 @@ void Grass::Init(RTerrain terrain, CSZ atlasUrl)
|
|||
_bushMask = 0;
|
||||
|
||||
if (!Math::IsPowerOfTwo(_pTerrain->GetMapSide()))
|
||||
throw VERUS_RECOVERABLE << "Init(), mapSide must be power of two";
|
||||
throw VERUS_RECOVERABLE << "Init(); mapSide must be power of two";
|
||||
|
||||
_mapSide = _pTerrain->GetMapSide();
|
||||
_mapShift = Math::HighestBit(_mapSide);
|
||||
|
@ -451,7 +451,7 @@ void Grass::LoadLayersFromFile(CSZ url)
|
|||
pugi::xml_document doc;
|
||||
const pugi::xml_parse_result result = doc.load_buffer_inplace(vData.data(), vData.size());
|
||||
if (!result)
|
||||
throw VERUS_RECOVERABLE << "load_buffer_inplace(), " << result.description();
|
||||
throw VERUS_RECOVERABLE << "load_buffer_inplace(); " << result.description();
|
||||
pugi::xml_node root = doc.first_child();
|
||||
for (auto node : root.children("grass"))
|
||||
{
|
||||
|
|
|
@ -120,6 +120,8 @@ namespace verus
|
|||
glm::vec4 _texEnableAlbedo = glm::vec4(0.5f, 0.5f, 0.5f, 1);
|
||||
TexturePwn _texNormal;
|
||||
glm::vec4 _texEnableNormal = glm::vec4(0.5f, 0.5f, 1.0f, 1);
|
||||
TexturePwn _texPacked;
|
||||
glm::vec4 _texEnablePacked = glm::vec4(0.5f, 0.5f, 1.0f, 1);
|
||||
glm::vec4 _userColor = glm::vec4(0, 0, 0, 0);
|
||||
Pick _userPick;
|
||||
Blending _blending = Blending::opaque;
|
||||
|
@ -183,6 +185,7 @@ namespace verus
|
|||
{
|
||||
TexturePwn _texDefaultAlbedo;
|
||||
TexturePwn _texDefaultNormal;
|
||||
TexturePwn _texDefaultPacked;
|
||||
TexturePwn _texDetail;
|
||||
TexturePwn _texStrass;
|
||||
CGI::CSHandle _cshDefault; // For missing, non-mandatory materials.
|
||||
|
|
|
@ -61,7 +61,7 @@ void Block::LoadExtra(SZ xml)
|
|||
pugi::xml_document doc;
|
||||
const pugi::xml_parse_result result = doc.load_buffer_inplace(xml, strlen(xml));
|
||||
if (!result)
|
||||
throw VERUS_RECOVERABLE << "load_buffer_inplace(), " << result.description();
|
||||
throw VERUS_RECOVERABLE << "load_buffer_inplace(); " << result.description();
|
||||
pugi::xml_node root = doc.first_child();
|
||||
|
||||
int lightCount = 0;
|
||||
|
|
|
@ -40,7 +40,7 @@ void Prefab::LoadPrefab(SZ xml)
|
|||
pugi::xml_document doc;
|
||||
const pugi::xml_parse_result result = doc.load_buffer_inplace(xml, strlen(xml));
|
||||
if (!result)
|
||||
throw VERUS_RECOVERABLE << "load_buffer_inplace(), " << result.description();
|
||||
throw VERUS_RECOVERABLE << "load_buffer_inplace(); " << result.description();
|
||||
pugi::xml_node root = doc.first_child();
|
||||
|
||||
int fragCount = 0;
|
||||
|
|
|
@ -433,7 +433,7 @@ void Terrain::Init(RcDesc desc)
|
|||
_mapShift = Math::HighestBit(_mapSide);
|
||||
|
||||
if (!Math::IsPowerOfTwo(_mapSide))
|
||||
throw VERUS_RECOVERABLE << "Init(), mapSide must be power of two";
|
||||
throw VERUS_RECOVERABLE << "Init(); mapSide must be power of two";
|
||||
|
||||
const int patchSide = _mapSide >> 4;
|
||||
const int patchShift = _mapShift - 4;
|
||||
|
@ -1188,7 +1188,7 @@ void Terrain::LoadLayersFromFile(CSZ url)
|
|||
pugi::xml_document doc;
|
||||
const pugi::xml_parse_result result = doc.load_buffer_inplace(vData.data(), vData.size());
|
||||
if (!result)
|
||||
throw VERUS_RECOVERABLE << "load_buffer_inplace(), " << result.description();
|
||||
throw VERUS_RECOVERABLE << "load_buffer_inplace(); " << result.description();
|
||||
pugi::xml_node root = doc.first_child();
|
||||
for (auto node : root.children("layer"))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue