mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-26 15:00:34 +00:00
Merge pull request #19569 from hrydgard/imgui-integration
ImGui integration prototype
This commit is contained in:
commit
c459d43f14
1
.gitignore
vendored
1
.gitignore
vendored
@ -103,6 +103,7 @@ r.sh
|
||||
Windows/compileData*
|
||||
Windows/*.ipch
|
||||
Windows/imgui.ini
|
||||
imgui.ini
|
||||
|
||||
# For vim
|
||||
*.swp
|
||||
|
@ -913,7 +913,7 @@ add_library(Common STATIC
|
||||
include_directories(Common)
|
||||
setup_target_project(Common Common)
|
||||
|
||||
target_link_libraries(Common Ext::Snappy cpu_features)
|
||||
target_link_libraries(Common Ext::Snappy cpu_features imgui)
|
||||
|
||||
if(ARM64)
|
||||
if(ANDROID)
|
||||
|
@ -403,6 +403,14 @@
|
||||
<ClInclude Include="..\ext\basis_universal\basisu_transcoder.h" />
|
||||
<ClInclude Include="..\ext\basis_universal\basisu_transcoder_internal.h" />
|
||||
<ClInclude Include="..\ext\basis_universal\basisu_transcoder_uastc.h" />
|
||||
<ClInclude Include="..\ext\imgui\imconfig.h" />
|
||||
<ClInclude Include="..\ext\imgui\imgui.h" />
|
||||
<ClInclude Include="..\ext\imgui\imgui_impl_platform.h" />
|
||||
<ClInclude Include="..\ext\imgui\imgui_impl_thin3d.h" />
|
||||
<ClInclude Include="..\ext\imgui\imgui_internal.h" />
|
||||
<ClInclude Include="..\ext\imgui\imstb_rectpack.h" />
|
||||
<ClInclude Include="..\ext\imgui\imstb_textedit.h" />
|
||||
<ClInclude Include="..\ext\imgui\imstb_truetype.h" />
|
||||
<ClInclude Include="..\ext\libpng17\png.h" />
|
||||
<ClInclude Include="..\ext\libpng17\pngconf.h" />
|
||||
<ClInclude Include="..\ext\libpng17\pngdebug.h" />
|
||||
@ -616,6 +624,13 @@
|
||||
<ClCompile Include="..\ext\at3_standalone\fft.cpp" />
|
||||
<ClCompile Include="..\ext\at3_standalone\mem.cpp" />
|
||||
<ClCompile Include="..\ext\basis_universal\basisu_transcoder.cpp" />
|
||||
<ClCompile Include="..\ext\imgui\imgui.cpp" />
|
||||
<ClCompile Include="..\ext\imgui\imgui_demo.cpp" />
|
||||
<ClCompile Include="..\ext\imgui\imgui_draw.cpp" />
|
||||
<ClCompile Include="..\ext\imgui\imgui_impl_platform.cpp" />
|
||||
<ClCompile Include="..\ext\imgui\imgui_impl_thin3d.cpp" />
|
||||
<ClCompile Include="..\ext\imgui\imgui_tables.cpp" />
|
||||
<ClCompile Include="..\ext\imgui\imgui_widgets.cpp" />
|
||||
<ClCompile Include="..\ext\libpng17\png.c">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
|
||||
@ -1051,6 +1066,7 @@
|
||||
<ItemGroup>
|
||||
<Text Include="..\ext\at3_standalone\CMakeLists.txt" />
|
||||
<Text Include="..\ext\at3_standalone\README.txt" />
|
||||
<Text Include="..\ext\imgui\CMakeLists.txt" />
|
||||
<Text Include="..\ext\libpng17\CMakeLists.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@ -1086,4 +1102,4 @@
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
@ -565,6 +565,30 @@
|
||||
<ClInclude Include="Log\LogManager.h">
|
||||
<Filter>Log</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ext\imgui\imstb_rectpack.h">
|
||||
<Filter>ext\imgui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ext\imgui\imstb_textedit.h">
|
||||
<Filter>ext\imgui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ext\imgui\imstb_truetype.h">
|
||||
<Filter>ext\imgui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ext\imgui\imconfig.h">
|
||||
<Filter>ext\imgui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ext\imgui\imgui.h">
|
||||
<Filter>ext\imgui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ext\imgui\imgui_impl_thin3d.h">
|
||||
<Filter>ext\imgui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ext\imgui\imgui_internal.h">
|
||||
<Filter>ext\imgui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ext\imgui\imgui_impl_platform.h">
|
||||
<Filter>ext\imgui</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="ABI.cpp" />
|
||||
@ -1057,6 +1081,27 @@
|
||||
<ClCompile Include="Log\LogManager.cpp">
|
||||
<Filter>Log</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\ext\imgui\imgui_widgets.cpp">
|
||||
<Filter>ext\imgui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\ext\imgui\imgui.cpp">
|
||||
<Filter>ext\imgui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\ext\imgui\imgui_demo.cpp">
|
||||
<Filter>ext\imgui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\ext\imgui\imgui_draw.cpp">
|
||||
<Filter>ext\imgui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\ext\imgui\imgui_impl_thin3d.cpp">
|
||||
<Filter>ext\imgui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\ext\imgui\imgui_tables.cpp">
|
||||
<Filter>ext\imgui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\ext\imgui\imgui_impl_platform.cpp">
|
||||
<Filter>ext\imgui</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="Crypto">
|
||||
@ -1176,6 +1221,9 @@
|
||||
<Filter Include="Log">
|
||||
<UniqueIdentifier>{cb2c7c09-1177-4a1e-962c-5cc7bcb56789}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="ext\imgui">
|
||||
<UniqueIdentifier>{87c4af9c-07fd-458e-8009-8b9f8b0e9b70}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="..\ext\libpng17\CMakeLists.txt">
|
||||
@ -1187,6 +1235,9 @@
|
||||
<Text Include="..\ext\at3_standalone\CMakeLists.txt">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</Text>
|
||||
<Text Include="..\ext\imgui\CMakeLists.txt">
|
||||
<Filter>ext\imgui</Filter>
|
||||
</Text>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\ext\basis_universal\basisu_transcoder_tables_astc.inc">
|
||||
|
@ -1,10 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <winapifamily.h>
|
||||
|
||||
// Utility file for using the MS CRT's memory tracking.
|
||||
// crtdbg.h overloads malloc with malloc_dbg etc, but does not catch new. So here we go.
|
||||
|
||||
// To add a full check of memory overruns, throw in a _CrtCheckMemory(). Useful to narrow things down.
|
||||
|
||||
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
||||
|
||||
#include <crtdbg.h>
|
||||
|
||||
#if defined(_DEBUG)
|
||||
@ -15,3 +19,5 @@
|
||||
#endif
|
||||
|
||||
#endif // _DEBUG
|
||||
|
||||
#endif
|
||||
|
@ -131,6 +131,9 @@ public:
|
||||
void Draw(int vertexCount, int offset) override;
|
||||
void DrawIndexed(int indexCount, int offset) override;
|
||||
void DrawUP(const void *vdata, int vertexCount) override;
|
||||
void DrawIndexedUP(const void *vdata, int vertexCount, const void *idata, int indexCount) override;
|
||||
void DrawIndexedClippedBatchUP(const void *vdata, int vertexCount, const void *idata, int indexCount, Slice<ClippedDraw> draws) override;
|
||||
|
||||
void Clear(int mask, uint32_t colorval, float depthVal, int stencilVal) override;
|
||||
|
||||
void BeginFrame(DebugFlags debugFlags) override;
|
||||
@ -235,6 +238,7 @@ private:
|
||||
// Temporaries
|
||||
ID3D11Texture2D *packTexture_ = nullptr;
|
||||
Buffer *upBuffer_ = nullptr;
|
||||
Buffer *upIBuffer_ = nullptr;
|
||||
|
||||
// System info
|
||||
D3D_FEATURE_LEVEL featureLevel_;
|
||||
@ -255,6 +259,8 @@ D3D11DrawContext::D3D11DrawContext(ID3D11Device *device, ID3D11DeviceContext *de
|
||||
// We no longer support Windows Phone.
|
||||
_assert_(featureLevel_ >= D3D_FEATURE_LEVEL_9_3);
|
||||
|
||||
caps_.coordConvention = CoordConvention::Direct3D11;
|
||||
|
||||
// Seems like a fair approximation...
|
||||
caps_.dualSourceBlend = featureLevel_ >= D3D_FEATURE_LEVEL_10_0;
|
||||
caps_.depthClampSupported = featureLevel_ >= D3D_FEATURE_LEVEL_10_0;
|
||||
@ -351,6 +357,7 @@ D3D11DrawContext::D3D11DrawContext(ID3D11Device *device, ID3D11DeviceContext *de
|
||||
const size_t UP_MAX_BYTES = 65536 * 24;
|
||||
|
||||
upBuffer_ = D3D11DrawContext::CreateBuffer(UP_MAX_BYTES, BufferUsageFlag::DYNAMIC | BufferUsageFlag::VERTEXDATA);
|
||||
upIBuffer_ = D3D11DrawContext::CreateBuffer(UP_MAX_BYTES, BufferUsageFlag::DYNAMIC | BufferUsageFlag::INDEXDATA);
|
||||
|
||||
IDXGIDevice1 *dxgiDevice1 = nullptr;
|
||||
hr = device_->QueryInterface(__uuidof(IDXGIDevice), reinterpret_cast<void **>(&dxgiDevice1));
|
||||
@ -364,6 +371,7 @@ D3D11DrawContext::~D3D11DrawContext() {
|
||||
DestroyPresets();
|
||||
|
||||
upBuffer_->Release();
|
||||
upIBuffer_->Release();
|
||||
packTexture_->Release();
|
||||
|
||||
// Release references.
|
||||
@ -1347,8 +1355,6 @@ void D3D11DrawContext::DrawIndexed(int indexCount, int offset) {
|
||||
}
|
||||
|
||||
void D3D11DrawContext::DrawUP(const void *vdata, int vertexCount) {
|
||||
ApplyCurrentState();
|
||||
|
||||
int byteSize = vertexCount * curPipeline_->input->stride;
|
||||
|
||||
UpdateBuffer(upBuffer_, (const uint8_t *)vdata, 0, byteSize, Draw::UPDATE_DISCARD);
|
||||
@ -1357,6 +1363,41 @@ void D3D11DrawContext::DrawUP(const void *vdata, int vertexCount) {
|
||||
Draw(vertexCount, offset);
|
||||
}
|
||||
|
||||
void D3D11DrawContext::DrawIndexedUP(const void *vdata, int vertexCount, const void *idata, int indexCount) {
|
||||
int vbyteSize = vertexCount * curPipeline_->input->stride;
|
||||
int ibyteSize = indexCount * sizeof(u16);
|
||||
|
||||
UpdateBuffer(upBuffer_, (const uint8_t *)vdata, 0, vbyteSize, Draw::UPDATE_DISCARD);
|
||||
BindVertexBuffer(upBuffer_, 0);
|
||||
|
||||
UpdateBuffer(upIBuffer_, (const uint8_t *)idata, 0, ibyteSize, Draw::UPDATE_DISCARD);
|
||||
BindIndexBuffer(upIBuffer_, 0);
|
||||
DrawIndexed(indexCount, 0);
|
||||
}
|
||||
|
||||
void D3D11DrawContext::DrawIndexedClippedBatchUP(const void *vdata, int vertexCount, const void *idata, int indexCount, Slice<ClippedDraw> draws) {
|
||||
int vbyteSize = vertexCount * curPipeline_->input->stride;
|
||||
int ibyteSize = indexCount * sizeof(u16);
|
||||
|
||||
UpdateBuffer(upBuffer_, (const uint8_t *)vdata, 0, vbyteSize, Draw::UPDATE_DISCARD);
|
||||
BindVertexBuffer(upBuffer_, 0);
|
||||
|
||||
UpdateBuffer(upIBuffer_, (const uint8_t *)idata, 0, ibyteSize, Draw::UPDATE_DISCARD);
|
||||
BindIndexBuffer(upIBuffer_, 0);
|
||||
|
||||
ApplyCurrentState();
|
||||
|
||||
for (int i = 0; i < draws.size(); i++) {
|
||||
D3D11_RECT rc;
|
||||
rc.left = draws[i].clipx;
|
||||
rc.top = draws[i].clipy;
|
||||
rc.right = draws[i].clipx + draws[i].clipw;
|
||||
rc.bottom = draws[i].clipy + draws[i].cliph;
|
||||
context_->RSSetScissorRects(1, &rc);
|
||||
context_->DrawIndexed(draws[i].indexCount, draws[i].indexOffset, 0);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t D3D11DrawContext::GetDataFormatSupport(DataFormat fmt) const {
|
||||
DXGI_FORMAT giFmt = dataFormatToD3D11(fmt);
|
||||
if (giFmt == DXGI_FORMAT_UNKNOWN)
|
||||
|
@ -573,6 +573,7 @@ public:
|
||||
void Draw(int vertexCount, int offset) override;
|
||||
void DrawIndexed(int vertexCount, int offset) override;
|
||||
void DrawUP(const void *vdata, int vertexCount) override;
|
||||
void DrawIndexedUP(const void *vdata, int vertexCount, const void *idata, int indexCount) override;
|
||||
void Clear(int mask, uint32_t colorval, float depthVal, int stencilVal) override;
|
||||
|
||||
uint64_t GetNativeObject(NativeObject obj, void *srcObject) override {
|
||||
@ -716,6 +717,9 @@ D3D9Context::D3D9Context(IDirect3D9 *d3d, IDirect3D9Ex *d3dEx, int adapterId, ID
|
||||
if (FAILED(d3d->GetAdapterIdentifier(adapterId, 0, &identifier_))) {
|
||||
ERROR_LOG(Log::G3D, "Failed to get adapter identifier: %d", adapterId);
|
||||
}
|
||||
|
||||
caps_.coordConvention = CoordConvention::Direct3D9;
|
||||
|
||||
switch (identifier_.VendorId) {
|
||||
case 0x10DE: caps_.vendor = GPUVendor::VENDOR_NVIDIA; break;
|
||||
case 0x1002:
|
||||
@ -1172,6 +1176,16 @@ void D3D9Context::DrawUP(const void *vdata, int vertexCount) {
|
||||
device_->DrawPrimitiveUP(curPipeline_->prim, D3DPrimCount(curPipeline_->prim, vertexCount), vdata, curPipeline_->inputLayout->GetStride());
|
||||
}
|
||||
|
||||
void D3D9Context::DrawIndexedUP(const void *vdata, int vertexCount, const void *idata, int indexCount) {
|
||||
curPipeline_->inputLayout->Apply(device_);
|
||||
curPipeline_->Apply(device_, stencilRef_, stencilWriteMask_, stencilCompareMask_);
|
||||
ApplyDynamicState();
|
||||
|
||||
device_->DrawIndexedPrimitiveUP(curPipeline_->prim, 0, vertexCount, D3DPrimCount(curPipeline_->prim, indexCount),
|
||||
idata, D3DFMT_INDEX16,
|
||||
vdata, curPipeline_->inputLayout->GetStride());
|
||||
}
|
||||
|
||||
static uint32_t SwapRB(uint32_t c) {
|
||||
return (c & 0xFF00FF00) | ((c >> 16) & 0xFF) | ((c << 16) & 0xFF0000);
|
||||
}
|
||||
|
@ -2,6 +2,9 @@
|
||||
|
||||
#include "Common/Common.h"
|
||||
|
||||
#include <functional>
|
||||
#include <cstdint>
|
||||
|
||||
// Flags and structs shared between backends that haven't found a good home.
|
||||
|
||||
enum class InvalidationFlags {
|
||||
@ -35,3 +38,11 @@ struct FrameTimeData {
|
||||
double presentMargin;
|
||||
};
|
||||
constexpr size_t FRAME_TIME_HISTORY_LENGTH = 32;
|
||||
|
||||
// Different APIs use different coordinate conventions
|
||||
enum class CoordConvention {
|
||||
Direct3D9,
|
||||
Direct3D11,
|
||||
Vulkan,
|
||||
OpenGL,
|
||||
};
|
||||
|
@ -443,6 +443,8 @@ public:
|
||||
void Draw(int vertexCount, int offset) override;
|
||||
void DrawIndexed(int vertexCount, int offset) override;
|
||||
void DrawUP(const void *vdata, int vertexCount) override;
|
||||
void DrawIndexedUP(const void *vdata, int vertexCount, const void *idata, int indexCount) override;
|
||||
void DrawIndexedClippedBatchUP(const void *vdata, int vertexCount, const void *idata, int indexCount, Slice<ClippedDraw> draws) override;
|
||||
|
||||
void Clear(int mask, uint32_t colorval, float depthVal, int stencilVal) override;
|
||||
|
||||
@ -572,6 +574,7 @@ OpenGLContext::OpenGLContext(bool canChangeSwapInterval) : renderManager_(frameT
|
||||
caps_.textureDepthSupported = true;
|
||||
}
|
||||
|
||||
caps_.coordConvention = CoordConvention::OpenGL;
|
||||
caps_.setMaxFrameLatencySupported = true;
|
||||
caps_.dualSourceBlend = gl_extensions.ARB_blend_func_extended || gl_extensions.EXT_blend_func_extended;
|
||||
caps_.anisoSupported = gl_extensions.EXT_texture_filter_anisotropic;
|
||||
@ -1417,6 +1420,59 @@ void OpenGLContext::DrawUP(const void *vdata, int vertexCount) {
|
||||
renderManager_.Draw(curPipeline_->inputLayout->inputLayout_, buf, offset, curPipeline_->prim, 0, vertexCount);
|
||||
}
|
||||
|
||||
void OpenGLContext::DrawIndexedUP(const void *vdata, int vertexCount, const void *idata, int indexCount) {
|
||||
_assert_(curPipeline_->inputLayout != nullptr);
|
||||
int stride = curPipeline_->inputLayout->stride;
|
||||
uint32_t vdataSize = stride * vertexCount;
|
||||
uint32_t idataSize = indexCount * sizeof(u16);
|
||||
|
||||
FrameData &frameData = frameData_[renderManager_.GetCurFrame()];
|
||||
|
||||
GLRBuffer *vbuf;
|
||||
uint32_t voffset;
|
||||
uint8_t *dest = frameData.push->Allocate(vdataSize, 4, &vbuf, &voffset);
|
||||
memcpy(dest, vdata, vdataSize);
|
||||
|
||||
GLRBuffer *ibuf;
|
||||
uint32_t ioffset;
|
||||
dest = frameData.push->Allocate(idataSize, 4, &ibuf, &ioffset);
|
||||
memcpy(dest, idata, idataSize);
|
||||
|
||||
ApplySamplers();
|
||||
renderManager_.DrawIndexed(curPipeline_->inputLayout->inputLayout_, vbuf, voffset, ibuf, ioffset, curPipeline_->prim, 0, GL_UNSIGNED_SHORT, vertexCount);
|
||||
}
|
||||
|
||||
void OpenGLContext::DrawIndexedClippedBatchUP(const void *vdata, int vertexCount, const void *idata, int indexCount, Slice<ClippedDraw> draws) {
|
||||
_assert_(curPipeline_->inputLayout != nullptr);
|
||||
int stride = curPipeline_->inputLayout->stride;
|
||||
uint32_t vdataSize = stride * vertexCount;
|
||||
int indexSize = sizeof(u16);
|
||||
uint32_t idataSize = indexCount * indexSize;
|
||||
|
||||
FrameData &frameData = frameData_[renderManager_.GetCurFrame()];
|
||||
|
||||
GLRBuffer *vbuf;
|
||||
uint32_t voffset;
|
||||
uint8_t *dest = frameData.push->Allocate(vdataSize, 4, &vbuf, &voffset);
|
||||
memcpy(dest, vdata, vdataSize);
|
||||
|
||||
GLRBuffer *ibuf;
|
||||
uint32_t ioffset;
|
||||
dest = frameData.push->Allocate(idataSize, 4, &ibuf, &ioffset);
|
||||
memcpy(dest, idata, idataSize);
|
||||
|
||||
ApplySamplers();
|
||||
for (auto &draw : draws) {
|
||||
GLRect2D scissor;
|
||||
scissor.x = draw.clipx;
|
||||
scissor.y = draw.clipy;
|
||||
scissor.w = draw.clipw;
|
||||
scissor.h = draw.cliph;
|
||||
renderManager_.SetScissor(scissor);
|
||||
renderManager_.DrawIndexed(curPipeline_->inputLayout->inputLayout_, vbuf, voffset, ibuf, ioffset + draw.indexOffset * indexSize, curPipeline_->prim, 0, GL_UNSIGNED_SHORT, draw.indexCount);
|
||||
}
|
||||
}
|
||||
|
||||
void OpenGLContext::Clear(int mask, uint32_t colorval, float depthVal, int stencilVal) {
|
||||
float col[4];
|
||||
Uint8x4ToFloat4(col, colorval);
|
||||
|
@ -491,6 +491,9 @@ public:
|
||||
void Draw(int vertexCount, int offset) override;
|
||||
void DrawIndexed(int vertexCount, int offset) override;
|
||||
void DrawUP(const void *vdata, int vertexCount) override;
|
||||
void DrawIndexedUP(const void *vdata, int vertexCount, const void *idata, int indexCount) override;
|
||||
// Specialized for quick IMGUI drawing.
|
||||
void DrawIndexedClippedBatchUP(const void *vdata, int vertexCount, const void *idata, int indexCount, Slice<ClippedDraw>) override;
|
||||
|
||||
void BindCurrentPipeline();
|
||||
void ApplyDynamicState();
|
||||
@ -879,6 +882,7 @@ VKContext::VKContext(VulkanContext *vulkan, bool useRenderThread)
|
||||
|
||||
INFO_LOG(Log::G3D, "Determining Vulkan device caps");
|
||||
|
||||
caps_.coordConvention = CoordConvention::Vulkan;
|
||||
caps_.setMaxFrameLatencySupported = true;
|
||||
caps_.anisoSupported = vulkan->GetDeviceFeatures().enabled.standard.samplerAnisotropy != 0;
|
||||
caps_.geometryShaderSupported = vulkan->GetDeviceFeatures().enabled.standard.geometryShader != 0;
|
||||
@ -1520,7 +1524,74 @@ void VKContext::DrawUP(const void *vdata, int vertexCount) {
|
||||
int descSetIndex;
|
||||
PackedDescriptor *descriptors = renderManager_.PushDescriptorSet(4, &descSetIndex);
|
||||
BindDescriptors(vulkanUBObuf, descriptors);
|
||||
renderManager_.Draw(descSetIndex, 1, &ubo_offset, vulkanVbuf, (int)vbBindOffset + curVBufferOffset_, vertexCount);
|
||||
renderManager_.Draw(descSetIndex, 1, &ubo_offset, vulkanVbuf, (int)vbBindOffset, vertexCount);
|
||||
}
|
||||
|
||||
void VKContext::DrawIndexedUP(const void *vdata, int vertexCount, const void *idata, int indexCount) {
|
||||
_dbg_assert_(vertexCount >= 0);
|
||||
_dbg_assert_(indexCount >= 0);
|
||||
if (vertexCount <= 0 || indexCount <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
VkBuffer vulkanVbuf, vulkanIbuf, vulkanUBObuf;
|
||||
size_t vdataSize = vertexCount * curPipeline_->stride;
|
||||
uint32_t vbBindOffset;
|
||||
uint8_t *vdataPtr = push_->Allocate(vdataSize, 4, &vulkanVbuf, &vbBindOffset);
|
||||
_assert_(vdataPtr != nullptr);
|
||||
memcpy(vdataPtr, vdata, vdataSize);
|
||||
|
||||
size_t idataSize = indexCount * sizeof(u16);
|
||||
uint32_t ibBindOffset;
|
||||
uint8_t *idataPtr = push_->Allocate(idataSize, 4, &vulkanIbuf, &ibBindOffset);
|
||||
_assert_(idataPtr != nullptr);
|
||||
memcpy(idataPtr, vdata, idataSize);
|
||||
|
||||
uint32_t ubo_offset = (uint32_t)curPipeline_->PushUBO(push_, vulkan_, &vulkanUBObuf);
|
||||
|
||||
BindCurrentPipeline();
|
||||
ApplyDynamicState();
|
||||
int descSetIndex;
|
||||
PackedDescriptor *descriptors = renderManager_.PushDescriptorSet(4, &descSetIndex);
|
||||
BindDescriptors(vulkanUBObuf, descriptors);
|
||||
renderManager_.DrawIndexed(descSetIndex, 1, &ubo_offset, vulkanVbuf, (int)vbBindOffset, vulkanIbuf, (int)ibBindOffset, indexCount, 1);
|
||||
}
|
||||
|
||||
void VKContext::DrawIndexedClippedBatchUP(const void *vdata, int vertexCount, const void *idata, int indexCount, Slice<ClippedDraw> draws) {
|
||||
_dbg_assert_(vertexCount >= 0);
|
||||
_dbg_assert_(indexCount >= 0);
|
||||
if (vertexCount <= 0 || indexCount <= 0 || draws.is_empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
VkBuffer vulkanVbuf, vulkanIbuf, vulkanUBObuf;
|
||||
size_t vdataSize = vertexCount * curPipeline_->stride;
|
||||
uint32_t vbBindOffset;
|
||||
uint8_t *vdataPtr = push_->Allocate(vdataSize, 4, &vulkanVbuf, &vbBindOffset);
|
||||
_assert_(vdataPtr != nullptr);
|
||||
memcpy(vdataPtr, vdata, vdataSize);
|
||||
|
||||
constexpr int indexSize = sizeof(u16);
|
||||
|
||||
size_t idataSize = indexCount * indexSize;
|
||||
uint32_t ibBindOffset;
|
||||
uint8_t *idataPtr = push_->Allocate(idataSize, 4, &vulkanIbuf, &ibBindOffset);
|
||||
_assert_(idataPtr != nullptr);
|
||||
memcpy(idataPtr, idata, idataSize);
|
||||
|
||||
uint32_t ubo_offset = (uint32_t)curPipeline_->PushUBO(push_, vulkan_, &vulkanUBObuf);
|
||||
|
||||
BindCurrentPipeline();
|
||||
ApplyDynamicState();
|
||||
int descSetIndex;
|
||||
PackedDescriptor *descriptors = renderManager_.PushDescriptorSet(4, &descSetIndex);
|
||||
|
||||
for (auto &draw : draws) {
|
||||
BindDescriptors(vulkanUBObuf, descriptors);
|
||||
renderManager_.SetScissor(draw.clipx, draw.clipy, draw.clipw, draw.cliph);
|
||||
renderManager_.DrawIndexed(descSetIndex, 1, &ubo_offset, vulkanVbuf, (int)vbBindOffset, vulkanIbuf,
|
||||
(int)ibBindOffset + draw.indexOffset * indexSize, draw.indexCount, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void VKContext::BindCurrentPipeline() {
|
||||
|
@ -581,6 +581,7 @@ struct DeviceCaps {
|
||||
GPUVendor vendor;
|
||||
uint32_t deviceID; // use caution!
|
||||
|
||||
CoordConvention coordConvention;
|
||||
DataFormat preferredDepthBufferFormat;
|
||||
DataFormat preferredShadowMapFormatLow;
|
||||
DataFormat preferredShadowMapFormatHigh;
|
||||
@ -693,6 +694,15 @@ struct BackendState {
|
||||
bool valid;
|
||||
};
|
||||
|
||||
struct ClippedDraw {
|
||||
int indexOffset;
|
||||
int indexCount;
|
||||
s16 clipx;
|
||||
s16 clipy;
|
||||
s16 clipw;
|
||||
s16 cliph;
|
||||
};
|
||||
|
||||
class DrawContext {
|
||||
public:
|
||||
virtual ~DrawContext() = default;
|
||||
@ -827,7 +837,9 @@ public:
|
||||
virtual void Draw(int vertexCount, int offset) = 0;
|
||||
virtual void DrawIndexed(int vertexCount, int offset) = 0; // Always 16-bit indices.
|
||||
virtual void DrawUP(const void *vdata, int vertexCount) = 0;
|
||||
|
||||
virtual void DrawIndexedUP(const void *vdata, int vertexCount, const void *idata, int indexCount) = 0; // Supports 32-bit indices, for IMGUI use.
|
||||
virtual void DrawIndexedClippedBatchUP(const void *vdata, int vertexCount, const void *idata, int indexCount, Slice<ClippedDraw> draws) {}
|
||||
|
||||
// Frame management (for the purposes of sync and resource management, necessary with modern APIs). Default implementations here.
|
||||
virtual void BeginFrame(DebugFlags debugFlags) = 0;
|
||||
virtual void EndFrame() = 0;
|
||||
|
@ -134,8 +134,9 @@ enum {
|
||||
TOUCH_UP = 1 << 2,
|
||||
TOUCH_CANCEL = 1 << 3, // Sent by scrollviews to their children when they detect a scroll
|
||||
TOUCH_WHEEL = 1 << 4, // Scrollwheel event. Usually only affects Y but can potentially affect X.
|
||||
TOUCH_MOUSE = 1 << 5, // Identifies that this touch event came from a mouse
|
||||
TOUCH_MOUSE = 1 << 5, // Identifies that this touch event came from a mouse. Id is now set to the mouse button for DOWN/UP commands.
|
||||
TOUCH_RELEASE_ALL = 1 << 6, // Useful for app focus switches when events may be lost.
|
||||
TOUCH_HOVER = 1 << 7,
|
||||
|
||||
// These are the Android getToolType() codes, shifted by 10.
|
||||
TOUCH_TOOL_MASK = 7 << 10,
|
||||
@ -153,6 +154,7 @@ struct TouchInput {
|
||||
float x;
|
||||
float y;
|
||||
int id; // Needs to be <= GestureDetector::MAX_PTRS (10.)
|
||||
int buttons; // bit mask
|
||||
int flags;
|
||||
double timestamp;
|
||||
};
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include "Common/System/Display.h"
|
||||
#include "Common/Math/math_util.h"
|
||||
#include "Common/GPU/MiscTypes.h"
|
||||
|
||||
DisplayProperties g_display;
|
||||
|
||||
@ -66,3 +67,35 @@ void DisplayProperties::Print() {
|
||||
printf("rotation: %d\n", (int)rotation);
|
||||
rot_matrix.print();
|
||||
}
|
||||
|
||||
Lin::Matrix4x4 ComputeOrthoMatrix(float xres, float yres, CoordConvention coordConvention) {
|
||||
using namespace Lin;
|
||||
// TODO: Should be able to share the y-flip logic here with the one in postprocessing/presentation, for example.
|
||||
Matrix4x4 ortho;
|
||||
switch (coordConvention) {
|
||||
case CoordConvention::Vulkan:
|
||||
ortho.setOrthoD3D(0.0f, xres, 0, yres, -1.0f, 1.0f);
|
||||
break;
|
||||
case CoordConvention::Direct3D9:
|
||||
ortho.setOrthoD3D(0.0f, xres, yres, 0.0f, -1.0f, 1.0f);
|
||||
Matrix4x4 translation;
|
||||
// Account for the small window adjustment.
|
||||
translation.setTranslation(Vec3(
|
||||
-0.5f * g_display.dpi_scale_x / g_display.dpi_scale_real_x,
|
||||
-0.5f * g_display.dpi_scale_y / g_display.dpi_scale_real_y, 0.0f));
|
||||
ortho = translation * ortho;
|
||||
break;
|
||||
case CoordConvention::Direct3D11:
|
||||
ortho.setOrthoD3D(0.0f, xres, yres, 0.0f, -1.0f, 1.0f);
|
||||
break;
|
||||
case CoordConvention::OpenGL:
|
||||
default:
|
||||
ortho.setOrtho(0.0f, xres, yres, 0.0f, -1.0f, 1.0f);
|
||||
break;
|
||||
}
|
||||
// Compensate for rotated display if needed.
|
||||
if (g_display.rotation != DisplayRotation::ROTATE_0) {
|
||||
ortho = ortho * g_display.rot_matrix;
|
||||
}
|
||||
return ortho;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Common/Math/lin/matrix4x4.h"
|
||||
#include "Common/GPU/MiscTypes.h"
|
||||
|
||||
// This is meant to be a framework for handling DPI scaling etc.
|
||||
// For now, it just consists of these ugly globals.
|
||||
@ -50,3 +51,5 @@ struct DisplayRect {
|
||||
|
||||
void RotateRectToDisplay(DisplayRect<float> &rect, float rtWidth, float rtHeight);
|
||||
void RotateRectToDisplay(DisplayRect<int> &rect, int rtWidth, int rtHeight);
|
||||
|
||||
Lin::Matrix4x4 ComputeOrthoMatrix(float xres, float yres, CoordConvention coordConvention);
|
||||
|
@ -249,6 +249,11 @@ bool Clickable::Touch(const TouchInput &input) {
|
||||
return contains;
|
||||
}
|
||||
|
||||
// Ignore buttons other than the left one.
|
||||
if ((input.flags & TOUCH_MOUSE) && (input.buttons & 1) == 0) {
|
||||
return contains;
|
||||
}
|
||||
|
||||
if (input.flags & TOUCH_DOWN) {
|
||||
if (bounds_.Contains(input.x, input.y)) {
|
||||
if (IsFocusMovementEnabled())
|
||||
|
@ -436,6 +436,7 @@ const KeyMap_IntStrPair psp_button_names[] = {
|
||||
#if !defined(MOBILE_DEVICE)
|
||||
{VIRTKEY_TOGGLE_FULLSCREEN, "Toggle Fullscreen"},
|
||||
#endif
|
||||
{VIRTKEY_TOGGLE_DEBUGGER, "Toggle Debugger"},
|
||||
|
||||
{VIRTKEY_OPENCHAT, "OpenChat" },
|
||||
|
||||
|
@ -77,6 +77,7 @@ enum {
|
||||
VIRTKEY_TOGGLE_MOUSE = 0x40000030,
|
||||
VIRTKEY_TOGGLE_TOUCH_CONTROLS = 0x40000031,
|
||||
VIRTKEY_RESET_EMULATION = 0x40000032,
|
||||
VIRTKEY_TOGGLE_DEBUGGER = 0x40000033,
|
||||
VIRTKEY_LAST,
|
||||
VIRTKEY_COUNT = VIRTKEY_LAST - VIRTKEY_FIRST
|
||||
};
|
||||
|
@ -45,6 +45,7 @@ static const DefMappingStruct defaultQwertyKeyboardKeyMap[] = {
|
||||
{VIRTKEY_PAUSE , NKCODE_ESCAPE},
|
||||
{VIRTKEY_REWIND , NKCODE_DEL},
|
||||
{VIRTKEY_ANALOG_LIGHTLY, NKCODE_SHIFT_RIGHT},
|
||||
{VIRTKEY_TOGGLE_DEBUGGER, NKCODE_F12},
|
||||
};
|
||||
|
||||
static const DefMappingStruct defaultAzertyKeyboardKeyMap[] = {
|
||||
|
@ -94,6 +94,10 @@ using namespace std::placeholders;
|
||||
#include "UI/ChatScreen.h"
|
||||
#include "UI/DebugOverlay.h"
|
||||
|
||||
#include "ext/imgui/imgui.h"
|
||||
#include "ext/imgui/imgui_impl_thin3d.h"
|
||||
#include "ext/imgui/imgui_impl_platform.h"
|
||||
|
||||
#include "Core/Reporting.h"
|
||||
|
||||
#if PPSSPP_PLATFORM(WINDOWS) && !PPSSPP_PLATFORM(UWP)
|
||||
@ -198,6 +202,10 @@ EmuScreen::EmuScreen(const Path &filename)
|
||||
// Usually, we don't want focus movement enabled on this screen, so disable on start.
|
||||
// Only if you open chat or dev tools do we want it to start working.
|
||||
UI::EnableFocusMovement(false);
|
||||
|
||||
// TODO: Do this only on demand.
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
}
|
||||
|
||||
bool EmuScreen::bootAllowStorage(const Path &filename) {
|
||||
@ -438,6 +446,11 @@ void EmuScreen::bootComplete() {
|
||||
}
|
||||
|
||||
EmuScreen::~EmuScreen() {
|
||||
Draw::DrawContext *draw = screenManager()->getDrawContext();
|
||||
ImGui_ImplThin3d_Shutdown(draw);
|
||||
|
||||
ImGui::DestroyContext();
|
||||
|
||||
std::string gameID = g_paramSFO.GetValueString("DISC_ID");
|
||||
g_Config.TimeTracker().Stop(gameID);
|
||||
|
||||
@ -642,7 +655,9 @@ bool EmuScreen::UnsyncTouch(const TouchInput &touch) {
|
||||
}
|
||||
}
|
||||
|
||||
GamepadTouch();
|
||||
if (!(imguiVisible_ && imguiInited_)) {
|
||||
GamepadTouch();
|
||||
}
|
||||
|
||||
if (root_) {
|
||||
UIScreen::UnsyncTouch(touch);
|
||||
@ -655,6 +670,11 @@ void EmuScreen::onVKey(int virtualKeyCode, bool down) {
|
||||
auto mc = GetI18NCategory(I18NCat::MAPPABLECONTROLS);
|
||||
|
||||
switch (virtualKeyCode) {
|
||||
case VIRTKEY_TOGGLE_DEBUGGER:
|
||||
if (down) {
|
||||
imguiVisible_ = !imguiVisible_;
|
||||
}
|
||||
break;
|
||||
case VIRTKEY_FASTFORWARD:
|
||||
if (down) {
|
||||
if (coreState == CORE_STEPPING) {
|
||||
@ -931,8 +951,22 @@ void EmuScreen::onVKeyAnalog(int virtualKeyCode, float value) {
|
||||
|
||||
bool EmuScreen::UnsyncKey(const KeyInput &key) {
|
||||
System_Notify(SystemNotification::ACTIVITY);
|
||||
if (UI::IsFocusMovementEnabled() || (imguiVisible_ && imguiInited_)) {
|
||||
// Note: Allow some Vkeys through, so we can toggle the imgui for example (since we actually block the control mapper otherwise in imgui mode).
|
||||
// We need to manually implement it here :/
|
||||
if (imguiVisible_ && imguiInited_) {
|
||||
InputMapping mapping(key.deviceId, key.keyCode);
|
||||
std::vector<int> pspButtons;
|
||||
bool mappingFound = KeyMap::InputMappingToPspButton(mapping, &pspButtons);
|
||||
if (mappingFound) {
|
||||
for (auto b : pspButtons) {
|
||||
if (b == VIRTKEY_TOGGLE_DEBUGGER || b == VIRTKEY_PAUSE) {
|
||||
return controlMapper_.Key(key, &pauseTrigger_);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (UI::IsFocusMovementEnabled()) {
|
||||
return UIScreen::UnsyncKey(key);
|
||||
}
|
||||
return controlMapper_.Key(key, &pauseTrigger_);
|
||||
@ -941,6 +975,10 @@ bool EmuScreen::UnsyncKey(const KeyInput &key) {
|
||||
bool EmuScreen::key(const KeyInput &key) {
|
||||
bool retval = UIScreen::key(key);
|
||||
|
||||
if (!retval && imguiVisible_ && imguiInited_) {
|
||||
ImGui_ImplPlatform_KeyEvent(key);
|
||||
}
|
||||
|
||||
if (!retval && (key.flags & KEY_DOWN) != 0 && UI::IsEscapeKey(key)) {
|
||||
if (chatMenu_)
|
||||
chatMenu_->Close();
|
||||
@ -953,6 +991,14 @@ bool EmuScreen::key(const KeyInput &key) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
void EmuScreen::touch(const TouchInput &touch) {
|
||||
if (imguiVisible_ && imguiInited_) {
|
||||
ImGui_ImplPlatform_TouchEvent(touch);
|
||||
} else {
|
||||
UIScreen::touch(touch);
|
||||
}
|
||||
}
|
||||
|
||||
void EmuScreen::UnsyncAxis(const AxisInput *axes, size_t count) {
|
||||
System_Notify(SystemNotification::ACTIVITY);
|
||||
|
||||
@ -1571,6 +1617,23 @@ ScreenRenderFlags EmuScreen::render(ScreenRenderMode mode) {
|
||||
if (!(mode & ScreenRenderMode::TOP)) {
|
||||
darken();
|
||||
}
|
||||
|
||||
if (imguiVisible_ && !imguiInited_) {
|
||||
imguiInited_ = true;
|
||||
ImGui_ImplThin3d_Init(draw);
|
||||
}
|
||||
|
||||
if (imguiVisible_ && imguiInited_) {
|
||||
ImGui_ImplPlatform_NewFrame();
|
||||
ImGui_ImplThin3d_NewFrame(draw, ui_draw2d.GetDrawMatrix());
|
||||
|
||||
// Draw imgui on top. For now, all we have is the demo window.
|
||||
ImGui::NewFrame();
|
||||
ImGui::ShowDemoWindow(nullptr);
|
||||
ImGui::Render();
|
||||
|
||||
ImGui_ImplThin3d_RenderDrawData(ImGui::GetDrawData(), draw);
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
|
@ -56,6 +56,7 @@ public:
|
||||
|
||||
// We also need to do some special handling of queued UI events to handle closing the chat window.
|
||||
bool key(const KeyInput &key) override;
|
||||
void touch(const TouchInput &key) override;
|
||||
|
||||
protected:
|
||||
void darken();
|
||||
@ -124,4 +125,7 @@ private:
|
||||
std::atomic<bool> doFrameAdvance_{};
|
||||
|
||||
ControlMapper controlMapper_;
|
||||
|
||||
bool imguiInited_ = false;
|
||||
bool imguiVisible_ = false;
|
||||
};
|
||||
|
@ -1016,38 +1016,6 @@ void CallbackPostRender(UIContext *dc, void *userdata) {
|
||||
}
|
||||
}
|
||||
|
||||
static Matrix4x4 ComputeOrthoMatrix(float xres, float yres) {
|
||||
// TODO: Should be able to share the y-flip logic here with the one in postprocessing/presentation, for example.
|
||||
Matrix4x4 ortho;
|
||||
switch (GetGPUBackend()) {
|
||||
case GPUBackend::VULKAN:
|
||||
ortho.setOrthoD3D(0.0f, xres, 0, yres, -1.0f, 1.0f);
|
||||
break;
|
||||
case GPUBackend::DIRECT3D9:
|
||||
ortho.setOrthoD3D(0.0f, xres, yres, 0.0f, -1.0f, 1.0f);
|
||||
Matrix4x4 translation;
|
||||
// Account for the small window adjustment.
|
||||
translation.setTranslation(Vec3(
|
||||
-0.5f * g_display.dpi_scale_x / g_display.dpi_scale_real_x,
|
||||
-0.5f * g_display.dpi_scale_y / g_display.dpi_scale_real_y, 0.0f));
|
||||
ortho = translation * ortho;
|
||||
break;
|
||||
case GPUBackend::DIRECT3D11:
|
||||
ortho.setOrthoD3D(0.0f, xres, yres, 0.0f, -1.0f, 1.0f);
|
||||
break;
|
||||
case GPUBackend::OPENGL:
|
||||
default:
|
||||
ortho.setOrtho(0.0f, xres, yres, 0.0f, -1.0f, 1.0f);
|
||||
break;
|
||||
}
|
||||
|
||||
// Compensate for rotated display if needed.
|
||||
if (g_display.rotation != DisplayRotation::ROTATE_0) {
|
||||
ortho = ortho * g_display.rot_matrix;
|
||||
}
|
||||
return ortho;
|
||||
}
|
||||
|
||||
static void SendMouseDeltaAxis();
|
||||
|
||||
void NativeFrame(GraphicsContext *graphicsContext) {
|
||||
@ -1115,8 +1083,7 @@ void NativeFrame(GraphicsContext *graphicsContext) {
|
||||
g_requestManager.ProcessRequests();
|
||||
|
||||
// Apply the UIContext bounds as a 2D transformation matrix.
|
||||
// TODO: This should be moved into the draw context...
|
||||
Matrix4x4 ortho = ComputeOrthoMatrix(g_display.dp_xres, g_display.dp_yres);
|
||||
Matrix4x4 ortho = ComputeOrthoMatrix(g_display.dp_xres, g_display.dp_yres, graphicsContext->GetDrawContext()->GetDeviceCaps().coordConvention);
|
||||
|
||||
Draw::DebugFlags debugFlags = Draw::DebugFlags::NONE;
|
||||
if ((DebugOverlay)g_Config.iDebugOverlay == DebugOverlay::GPU_PROFILE)
|
||||
@ -1413,10 +1380,10 @@ static void SendMouseDeltaAxis() {
|
||||
}
|
||||
|
||||
void NativeMouseDelta(float dx, float dy) {
|
||||
// Remap, shared code. Then send it as a regular axis event.
|
||||
if (!g_Config.bMouseControl)
|
||||
return;
|
||||
|
||||
// Remap, shared code. Then send it as a regular axis event.
|
||||
MouseEventProcessor::ProcessDelta(time_now_d(), dx, dy);
|
||||
|
||||
SendMouseDeltaAxis();
|
||||
|
@ -260,6 +260,14 @@
|
||||
<ClInclude Include="..\..\ext\basis_universal\basisu_transcoder.h" />
|
||||
<ClInclude Include="..\..\ext\basis_universal\basisu_transcoder_internal.h" />
|
||||
<ClInclude Include="..\..\ext\basis_universal\basisu_transcoder_uastc.h" />
|
||||
<ClInclude Include="..\..\ext\imgui\imconfig.h" />
|
||||
<ClInclude Include="..\..\ext\imgui\imgui.h" />
|
||||
<ClInclude Include="..\..\ext\imgui\imgui_impl_platform.h" />
|
||||
<ClInclude Include="..\..\ext\imgui\imgui_impl_thin3d.h" />
|
||||
<ClInclude Include="..\..\ext\imgui\imgui_internal.h" />
|
||||
<ClInclude Include="..\..\ext\imgui\imstb_rectpack.h" />
|
||||
<ClInclude Include="..\..\ext\imgui\imstb_textedit.h" />
|
||||
<ClInclude Include="..\..\ext\imgui\imstb_truetype.h" />
|
||||
<ClInclude Include="..\..\ext\libpng17\png.h" />
|
||||
<ClInclude Include="..\..\ext\libpng17\pngconf.h" />
|
||||
<ClInclude Include="..\..\ext\libpng17\pngdebug.h" />
|
||||
@ -405,6 +413,13 @@
|
||||
<ClCompile Include="..\..\ext\at3_standalone\get_bits.cpp" />
|
||||
<ClCompile Include="..\..\ext\at3_standalone\mem.cpp" />
|
||||
<ClCompile Include="..\..\ext\basis_universal\basisu_transcoder.cpp" />
|
||||
<ClCompile Include="..\..\ext\imgui\imgui.cpp" />
|
||||
<ClCompile Include="..\..\ext\imgui\imgui_demo.cpp" />
|
||||
<ClCompile Include="..\..\ext\imgui\imgui_draw.cpp" />
|
||||
<ClCompile Include="..\..\ext\imgui\imgui_impl_platform.cpp" />
|
||||
<ClCompile Include="..\..\ext\imgui\imgui_impl_thin3d.cpp" />
|
||||
<ClCompile Include="..\..\ext\imgui\imgui_tables.cpp" />
|
||||
<ClCompile Include="..\..\ext\imgui\imgui_widgets.cpp" />
|
||||
<ClCompile Include="..\..\ext\libpng17\png.c" />
|
||||
<ClCompile Include="..\..\ext\libpng17\pngerror.c" />
|
||||
<ClCompile Include="..\..\ext\libpng17\pngget.c" />
|
||||
@ -453,4 +468,4 @@
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
@ -103,6 +103,9 @@
|
||||
<Filter Include="ext\at3_standalone">
|
||||
<UniqueIdentifier>{47e3b9c8-3a5f-4c78-b62b-3fa65bf23594}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="ext\imgui">
|
||||
<UniqueIdentifier>{06799036-06fd-4b7b-8c1d-5bdad62c2a24}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\Common\ABI.cpp" />
|
||||
@ -493,6 +496,27 @@
|
||||
<ClCompile Include="..\..\ext\at3_standalone\mem.cpp">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ext\imgui\imgui_tables.cpp">
|
||||
<Filter>ext\imgui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ext\imgui\imgui_widgets.cpp">
|
||||
<Filter>ext\imgui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ext\imgui\imgui.cpp">
|
||||
<Filter>ext\imgui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ext\imgui\imgui_demo.cpp">
|
||||
<Filter>ext\imgui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ext\imgui\imgui_draw.cpp">
|
||||
<Filter>ext\imgui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ext\imgui\imgui_impl_platform.cpp">
|
||||
<Filter>ext\imgui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ext\imgui\imgui_impl_thin3d.cpp">
|
||||
<Filter>ext\imgui</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="targetver.h" />
|
||||
@ -945,6 +969,30 @@
|
||||
<ClInclude Include="..\..\ext\at3_standalone\mem.h">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\ext\imgui\imstb_rectpack.h">
|
||||
<Filter>ext\imgui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\ext\imgui\imstb_textedit.h">
|
||||
<Filter>ext\imgui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\ext\imgui\imstb_truetype.h">
|
||||
<Filter>ext\imgui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\ext\imgui\imconfig.h">
|
||||
<Filter>ext\imgui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\ext\imgui\imgui.h">
|
||||
<Filter>ext\imgui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\ext\imgui\imgui_internal.h">
|
||||
<Filter>ext\imgui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\ext\imgui\imgui_impl_platform.h">
|
||||
<Filter>ext\imgui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\ext\imgui\imgui_impl_thin3d.h">
|
||||
<Filter>ext\imgui</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\Common\Math\fast\fast_matrix_neon.S">
|
||||
@ -993,4 +1041,4 @@
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</Text>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
@ -632,9 +632,9 @@ namespace MainWindow
|
||||
float y = GET_Y_LPARAM(lParam) * g_display.dpi_scale_y;
|
||||
WindowsRawInput::SetMousePos(x, y);
|
||||
|
||||
TouchInput touch;
|
||||
touch.id = 0;
|
||||
touch.flags = TOUCH_DOWN;
|
||||
TouchInput touch{};
|
||||
touch.flags = TOUCH_DOWN | TOUCH_MOUSE;
|
||||
touch.buttons = 1;
|
||||
touch.x = x;
|
||||
touch.y = y;
|
||||
NativeTouch(touch);
|
||||
@ -680,10 +680,15 @@ namespace MainWindow
|
||||
float y = (float)cursorY * g_display.dpi_scale_y;
|
||||
WindowsRawInput::SetMousePos(x, y);
|
||||
|
||||
if (wParam & MK_LBUTTON) {
|
||||
TouchInput touch;
|
||||
touch.id = 0;
|
||||
touch.flags = TOUCH_MOVE;
|
||||
if (wParam & (MK_LBUTTON | MK_RBUTTON)) {
|
||||
TouchInput touch{};
|
||||
touch.flags = TOUCH_MOVE | TOUCH_MOUSE;
|
||||
if (wParam & MK_LBUTTON) {
|
||||
touch.buttons |= 1;
|
||||
}
|
||||
if (wParam & MK_RBUTTON) {
|
||||
touch.buttons |= 2;
|
||||
}
|
||||
touch.x = x;
|
||||
touch.y = y;
|
||||
NativeTouch(touch);
|
||||
@ -702,9 +707,9 @@ namespace MainWindow
|
||||
float y = (float)GET_Y_LPARAM(lParam) * g_display.dpi_scale_y;
|
||||
WindowsRawInput::SetMousePos(x, y);
|
||||
|
||||
TouchInput touch;
|
||||
touch.id = 0;
|
||||
touch.flags = TOUCH_UP;
|
||||
TouchInput touch{};
|
||||
touch.buttons = 1;
|
||||
touch.flags = TOUCH_UP | TOUCH_MOUSE;
|
||||
touch.x = x;
|
||||
touch.y = y;
|
||||
NativeTouch(touch);
|
||||
@ -716,6 +721,34 @@ namespace MainWindow
|
||||
touchHandler.handleTouchEvent(hWnd, message, wParam, lParam);
|
||||
return 0;
|
||||
|
||||
case WM_RBUTTONDOWN:
|
||||
{
|
||||
float x = GET_X_LPARAM(lParam) * g_display.dpi_scale_x;
|
||||
float y = GET_Y_LPARAM(lParam) * g_display.dpi_scale_y;
|
||||
|
||||
TouchInput touch{};
|
||||
touch.buttons = 2;
|
||||
touch.flags = TOUCH_DOWN | TOUCH_MOUSE;
|
||||
touch.x = x;
|
||||
touch.y = y;
|
||||
NativeTouch(touch);
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_RBUTTONUP:
|
||||
{
|
||||
float x = GET_X_LPARAM(lParam) * g_display.dpi_scale_x;
|
||||
float y = GET_Y_LPARAM(lParam) * g_display.dpi_scale_y;
|
||||
|
||||
TouchInput touch{};
|
||||
touch.buttons = 2;
|
||||
touch.flags = TOUCH_UP | TOUCH_MOUSE;
|
||||
touch.x = x;
|
||||
touch.y = y;
|
||||
NativeTouch(touch);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
|
@ -186,6 +186,13 @@ EXT_FILES := \
|
||||
$(SRC)/ext/libpng17/pngwtran.c \
|
||||
$(SRC)/ext/libpng17/pngwutil.c \
|
||||
$(SRC)/ext/basis_universal/basisu_transcoder.cpp \
|
||||
$(SRC)/ext/imgui/imgui.cpp \
|
||||
$(SRC)/ext/imgui/imgui_demo.cpp \
|
||||
$(SRC)/ext/imgui/imgui_draw.cpp \
|
||||
$(SRC)/ext/imgui/imgui_impl_thin3d.cpp \
|
||||
$(SRC)/ext/imgui/imgui_impl_platform.cpp \
|
||||
$(SRC)/ext/imgui/imgui_tables.cpp \
|
||||
$(SRC)/ext/imgui/imgui_widgets.cpp \
|
||||
$(SRC)/ext/jpge/jpgd.cpp \
|
||||
$(SRC)/ext/jpge/jpge.cpp \
|
||||
$(SRC)/ext/sha1/sha1.cpp \
|
||||
|
@ -29,6 +29,7 @@ set(ENABLE_GLSLANG_INSTALL OFF)
|
||||
add_subdirectory(glslang EXCLUDE_FROM_ALL)
|
||||
add_subdirectory(snappy)
|
||||
add_subdirectory(minimp3)
|
||||
add_subdirectory(imgui)
|
||||
add_subdirectory(at3_standalone)
|
||||
add_subdirectory(udis86)
|
||||
add_subdirectory(SPIRV-Cross-build)
|
||||
|
12
ext/imgui/CMakeLists.txt
Normal file
12
ext/imgui/CMakeLists.txt
Normal file
@ -0,0 +1,12 @@
|
||||
set(IMGUI_FILES
|
||||
imgui.cpp
|
||||
imgui_demo.cpp
|
||||
imgui_draw.cpp
|
||||
imgui_tables.cpp
|
||||
imgui_widgets.cpp
|
||||
imgui_impl_thin3d.cpp
|
||||
imgui_impl_platform.cpp
|
||||
)
|
||||
|
||||
add_library(imgui ${IMGUI_FILES})
|
||||
target_include_directories(imgui PRIVATE ../..)
|
131
ext/imgui/imconfig.h
Normal file
131
ext/imgui/imconfig.h
Normal file
@ -0,0 +1,131 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// DEAR IMGUI COMPILE-TIME OPTIONS
|
||||
// Runtime options (clipboard callbacks, enabling various features, etc.) can generally be set via the ImGuiIO structure.
|
||||
// You can use ImGui::SetAllocatorFunctions() before calling ImGui::CreateContext() to rewire memory allocation functions.
|
||||
//-----------------------------------------------------------------------------
|
||||
// A) You may edit imconfig.h (and not overwrite it when updating Dear ImGui, or maintain a patch/rebased branch with your modifications to it)
|
||||
// B) or '#define IMGUI_USER_CONFIG "my_imgui_config.h"' in your project and then add directives in your own file without touching this template.
|
||||
//-----------------------------------------------------------------------------
|
||||
// You need to make sure that configuration settings are defined consistently _everywhere_ Dear ImGui is used, which include the imgui*.cpp
|
||||
// files but also _any_ of your code that uses Dear ImGui. This is because some compile-time options have an affect on data structures.
|
||||
// Defining those options in imconfig.h will ensure every compilation unit gets to see the same data structure layouts.
|
||||
// Call IMGUI_CHECKVERSION() from your .cpp file to verify that the data structures your files are using are matching the ones imgui.cpp is using.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
//---- Define assertion handler. Defaults to calling assert().
|
||||
// If your macro uses multiple statements, make sure is enclosed in a 'do { .. } while (0)' block so it can be used as a single statement.
|
||||
//#define IM_ASSERT(_EXPR) MyAssert(_EXPR)
|
||||
//#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts
|
||||
|
||||
//---- Define attributes of all API symbols declarations, e.g. for DLL under Windows
|
||||
// Using Dear ImGui via a shared library is not recommended, because of function call overhead and because we don't guarantee backward nor forward ABI compatibility.
|
||||
// DLL users: heaps and globals are not shared across DLL boundaries! You will need to call SetCurrentContext() + SetAllocatorFunctions()
|
||||
// for each static/DLL boundary you are calling from. Read "Context and Memory Allocators" section of imgui.cpp for more details.
|
||||
//#define IMGUI_API __declspec( dllexport )
|
||||
//#define IMGUI_API __declspec( dllimport )
|
||||
|
||||
//---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to clean your code of obsolete function/names.
|
||||
#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
//#define IMGUI_DISABLE_OBSOLETE_KEYIO // 1.87+ disable legacy io.KeyMap[]+io.KeysDown[] in favor io.AddKeyEvent(). This is automatically done by IMGUI_DISABLE_OBSOLETE_FUNCTIONS.
|
||||
|
||||
//---- Disable all of Dear ImGui or don't implement standard windows/tools.
|
||||
// It is very strongly recommended to NOT disable the demo windows and debug tool during development. They are extremely useful in day to day work. Please read comments in imgui_demo.cpp.
|
||||
//#define IMGUI_DISABLE // Disable everything: all headers and source files will be empty.
|
||||
//#define IMGUI_DISABLE_DEMO_WINDOWS // Disable demo windows: ShowDemoWindow()/ShowStyleEditor() will be empty.
|
||||
//#define IMGUI_DISABLE_DEBUG_TOOLS // Disable metrics/debugger and other debug tools: ShowMetricsWindow(), ShowDebugLogWindow() and ShowIDStackToolWindow() will be empty.
|
||||
|
||||
//---- Don't implement some functions to reduce linkage requirements.
|
||||
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc. (user32.lib/.a, kernel32.lib/.a)
|
||||
//#define IMGUI_ENABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] [Default with Visual Studio] Implement default IME handler (require imm32.lib/.a, auto-link for Visual Studio, -limm32 on command-line for MinGW)
|
||||
//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] [Default with non-Visual Studio compilers] Don't implement default IME handler (won't require imm32.lib/.a)
|
||||
//#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function (clipboard, IME).
|
||||
//#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS // [OSX] Implement default OSX clipboard handler (need to link with '-framework ApplicationServices', this is why this is not the default).
|
||||
//#define IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself (e.g. if you don't want to link with vsnprintf)
|
||||
//#define IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 so you can implement them yourself.
|
||||
//#define IMGUI_DISABLE_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle at all (replace them with dummies)
|
||||
//#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle so you can implement them yourself if you don't want to link with fopen/fclose/fread/fwrite. This will also disable the LogToTTY() function.
|
||||
//#define IMGUI_DISABLE_DEFAULT_ALLOCATORS // Don't implement default allocators calling malloc()/free() to avoid linking with them. You will need to call ImGui::SetAllocatorFunctions().
|
||||
//#define IMGUI_DISABLE_SSE // Disable use of SSE intrinsics even if available
|
||||
|
||||
//---- Include imgui_user.h at the end of imgui.h as a convenience
|
||||
// May be convenient for some users to only explicitly include vanilla imgui.h and have extra stuff included.
|
||||
//#define IMGUI_INCLUDE_IMGUI_USER_H
|
||||
//#define IMGUI_USER_H_FILENAME "my_folder/my_imgui_user.h"
|
||||
|
||||
//---- Pack colors to BGRA8 instead of RGBA8 (to avoid converting from one to another)
|
||||
//#define IMGUI_USE_BGRA_PACKED_COLOR
|
||||
|
||||
//---- Use 32-bit for ImWchar (default is 16-bit) to support Unicode planes 1-16. (e.g. point beyond 0xFFFF like emoticons, dingbats, symbols, shapes, ancient languages, etc...)
|
||||
//#define IMGUI_USE_WCHAR32
|
||||
|
||||
//---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version
|
||||
// By default the embedded implementations are declared static and not available outside of Dear ImGui sources files.
|
||||
//#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h"
|
||||
//#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h"
|
||||
//#define IMGUI_STB_SPRINTF_FILENAME "my_folder/stb_sprintf.h" // only used if IMGUI_USE_STB_SPRINTF is defined.
|
||||
//#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION
|
||||
//#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION
|
||||
//#define IMGUI_DISABLE_STB_SPRINTF_IMPLEMENTATION // only disabled if IMGUI_USE_STB_SPRINTF is defined.
|
||||
|
||||
//---- Use stb_sprintf.h for a faster implementation of vsnprintf instead of the one from libc (unless IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS is defined)
|
||||
// Compatibility checks of arguments and formats done by clang and GCC will be disabled in order to support the extra formats provided by stb_sprintf.h.
|
||||
//#define IMGUI_USE_STB_SPRINTF
|
||||
|
||||
//---- Use FreeType to build and rasterize the font atlas (instead of stb_truetype which is embedded by default in Dear ImGui)
|
||||
// Requires FreeType headers to be available in the include path. Requires program to be compiled with 'misc/freetype/imgui_freetype.cpp' (in this repository) + the FreeType library (not provided).
|
||||
// On Windows you may use vcpkg with 'vcpkg install freetype --triplet=x64-windows' + 'vcpkg integrate install'.
|
||||
//#define IMGUI_ENABLE_FREETYPE
|
||||
|
||||
//---- Use FreeType+lunasvg library to render OpenType SVG fonts (SVGinOT)
|
||||
// Requires lunasvg headers to be available in the include path + program to be linked with the lunasvg library (not provided).
|
||||
// Only works in combination with IMGUI_ENABLE_FREETYPE.
|
||||
// (implementation is based on Freetype's rsvg-port.c which is licensed under CeCILL-C Free Software License Agreement)
|
||||
//#define IMGUI_ENABLE_FREETYPE_LUNASVG
|
||||
|
||||
//---- Use stb_truetype to build and rasterize the font atlas (default)
|
||||
// The only purpose of this define is if you want force compilation of the stb_truetype backend ALONG with the FreeType backend.
|
||||
//#define IMGUI_ENABLE_STB_TRUETYPE
|
||||
|
||||
//---- Define constructor and implicit cast operators to convert back<>forth between your math types and ImVec2/ImVec4.
|
||||
// This will be inlined as part of ImVec2 and ImVec4 class declarations.
|
||||
/*
|
||||
#define IM_VEC2_CLASS_EXTRA \
|
||||
constexpr ImVec2(const MyVec2& f) : x(f.x), y(f.y) {} \
|
||||
operator MyVec2() const { return MyVec2(x,y); }
|
||||
|
||||
#define IM_VEC4_CLASS_EXTRA \
|
||||
constexpr ImVec4(const MyVec4& f) : x(f.x), y(f.y), z(f.z), w(f.w) {} \
|
||||
operator MyVec4() const { return MyVec4(x,y,z,w); }
|
||||
*/
|
||||
//---- ...Or use Dear ImGui's own very basic math operators.
|
||||
//#define IMGUI_DEFINE_MATH_OPERATORS
|
||||
|
||||
//---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices.
|
||||
// Your renderer backend will need to support it (most example renderer backends support both 16/32-bit indices).
|
||||
// Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer.
|
||||
// Read about ImGuiBackendFlags_RendererHasVtxOffset for details.
|
||||
//#define ImDrawIdx unsigned int
|
||||
|
||||
//---- Override ImDrawCallback signature (will need to modify renderer backends accordingly)
|
||||
//struct ImDrawList;
|
||||
//struct ImDrawCmd;
|
||||
//typedef void (*MyImDrawCallback)(const ImDrawList* draw_list, const ImDrawCmd* cmd, void* my_renderer_user_data);
|
||||
//#define ImDrawCallback MyImDrawCallback
|
||||
|
||||
//---- Debug Tools: Macro to break in Debugger (we provide a default implementation of this in the codebase)
|
||||
// (use 'Metrics->Tools->Item Picker' to pick widgets with the mouse and break into them for easy debugging.)
|
||||
//#define IM_DEBUG_BREAK IM_ASSERT(0)
|
||||
//#define IM_DEBUG_BREAK __debugbreak()
|
||||
|
||||
//---- Debug Tools: Enable slower asserts
|
||||
//#define IMGUI_DEBUG_PARANOID
|
||||
|
||||
//---- Tip: You can add extra functions within the ImGui:: namespace from anywhere (e.g. your own sources/header files)
|
||||
/*
|
||||
namespace ImGui
|
||||
{
|
||||
void MyFunction(const char* name, MyMatrix44* mtx);
|
||||
}
|
||||
*/
|
16054
ext/imgui/imgui.cpp
Normal file
16054
ext/imgui/imgui.cpp
Normal file
File diff suppressed because it is too large
Load Diff
3399
ext/imgui/imgui.h
Normal file
3399
ext/imgui/imgui.h
Normal file
File diff suppressed because it is too large
Load Diff
8759
ext/imgui/imgui_demo.cpp
Normal file
8759
ext/imgui/imgui_demo.cpp
Normal file
File diff suppressed because it is too large
Load Diff
4625
ext/imgui/imgui_draw.cpp
Normal file
4625
ext/imgui/imgui_draw.cpp
Normal file
File diff suppressed because it is too large
Load Diff
186
ext/imgui/imgui_impl_platform.cpp
Normal file
186
ext/imgui/imgui_impl_platform.cpp
Normal file
@ -0,0 +1,186 @@
|
||||
#include "ext/imgui/imgui.h"
|
||||
#include "Common/Input/KeyCodes.h"
|
||||
#include "Common/Data/Encoding/Utf8.h"
|
||||
#include "Common/System/Display.h"
|
||||
|
||||
#include "imgui_impl_platform.h"
|
||||
|
||||
void ImGui_ImplPlatform_KeyEvent(const KeyInput &key) {
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
|
||||
if (key.flags & KEY_DOWN) {
|
||||
ImGuiKey keyCode = KeyCodeToImGui(key.keyCode);
|
||||
if (keyCode == ImGuiKey_None) {
|
||||
WARN_LOG(Log::System, "Unmapped ImGui keycode conversion from %d", key.keyCode);
|
||||
}
|
||||
io.AddKeyEvent(keyCode, true);
|
||||
}
|
||||
if (key.flags & KEY_UP) {
|
||||
ImGuiKey keyCode = KeyCodeToImGui(key.keyCode);
|
||||
io.AddKeyEvent(keyCode, false);
|
||||
}
|
||||
if (key.flags & KEY_CHAR) {
|
||||
const int unichar = key.unicodeChar;
|
||||
if (unichar >= 0x20) {
|
||||
// Insert it! (todo: do it with a string insert)
|
||||
char buf[16];
|
||||
buf[u8_wc_toutf8(buf, unichar)] = '\0';
|
||||
io.AddInputCharactersUTF8(buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ImGui_ImplPlatform_TouchEvent(const TouchInput &touch) {
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
|
||||
// We use real pixels in the imgui, no DPI adjustment yet.
|
||||
float x = touch.x / g_display.dpi_scale_x;
|
||||
float y = touch.y / g_display.dpi_scale_y;
|
||||
|
||||
if (touch.flags & TOUCH_MOVE) {
|
||||
io.AddMousePosEvent(x, y);
|
||||
}
|
||||
if (touch.flags & TOUCH_DOWN) {
|
||||
io.AddMousePosEvent(x, y);
|
||||
if (touch.buttons & 1)
|
||||
io.AddMouseButtonEvent(0, true);
|
||||
if (touch.buttons & 2)
|
||||
io.AddMouseButtonEvent(1, true);
|
||||
}
|
||||
if (touch.flags & TOUCH_UP) {
|
||||
io.AddMousePosEvent(x, y);
|
||||
if (touch.buttons & 1)
|
||||
io.AddMouseButtonEvent(0, false);
|
||||
if (touch.buttons & 2)
|
||||
io.AddMouseButtonEvent(1, false);
|
||||
}
|
||||
}
|
||||
|
||||
void ImGui_ImplPlatform_AxisEvent(const AxisInput &axis) {
|
||||
// Ignore for now.
|
||||
}
|
||||
|
||||
void ImGui_ImplPlatform_NewFrame() {
|
||||
ImGuiIO &io = ImGui::GetIO();
|
||||
io.DisplaySize = ImVec2(g_display.pixel_xres, g_display.pixel_yres);
|
||||
io.DisplayFramebufferScale = ImVec2(1.0f, 1.0f);
|
||||
}
|
||||
|
||||
// Written by chatgpt
|
||||
ImGuiKey KeyCodeToImGui(InputKeyCode keyCode) {
|
||||
switch (keyCode) {
|
||||
case NKCODE_DPAD_UP: return ImGuiKey_UpArrow;
|
||||
case NKCODE_DPAD_DOWN: return ImGuiKey_DownArrow;
|
||||
case NKCODE_DPAD_LEFT: return ImGuiKey_LeftArrow;
|
||||
case NKCODE_DPAD_RIGHT: return ImGuiKey_RightArrow;
|
||||
case NKCODE_ENTER: return ImGuiKey_Enter;
|
||||
case NKCODE_ESCAPE: return ImGuiKey_Escape;
|
||||
case NKCODE_SHIFT_LEFT: return ImGuiKey_LeftShift;
|
||||
case NKCODE_SHIFT_RIGHT: return ImGuiKey_RightShift;
|
||||
case NKCODE_ALT_LEFT: return ImGuiKey_LeftAlt;
|
||||
case NKCODE_ALT_RIGHT: return ImGuiKey_RightAlt;
|
||||
case NKCODE_CTRL_LEFT: return ImGuiKey_LeftCtrl;
|
||||
case NKCODE_CTRL_RIGHT: return ImGuiKey_RightCtrl;
|
||||
case NKCODE_TAB: return ImGuiKey_Tab;
|
||||
case NKCODE_MENU: return ImGuiKey_Menu;
|
||||
case NKCODE_DEL: return ImGuiKey_Backspace;
|
||||
case NKCODE_FORWARD_DEL: return ImGuiKey_Delete;
|
||||
case NKCODE_CAPS_LOCK: return ImGuiKey_CapsLock;
|
||||
case NKCODE_SPACE: return ImGuiKey_Space;
|
||||
case NKCODE_PAGE_UP: return ImGuiKey_PageUp;
|
||||
case NKCODE_PAGE_DOWN: return ImGuiKey_PageDown;
|
||||
case NKCODE_MOVE_HOME: return ImGuiKey_Home;
|
||||
case NKCODE_MOVE_END: return ImGuiKey_End;
|
||||
case NKCODE_INSERT: return ImGuiKey_Insert;
|
||||
|
||||
// Numeric keys
|
||||
case NKCODE_0: return ImGuiKey_0;
|
||||
case NKCODE_1: return ImGuiKey_1;
|
||||
case NKCODE_2: return ImGuiKey_2;
|
||||
case NKCODE_3: return ImGuiKey_3;
|
||||
case NKCODE_4: return ImGuiKey_4;
|
||||
case NKCODE_5: return ImGuiKey_5;
|
||||
case NKCODE_6: return ImGuiKey_6;
|
||||
case NKCODE_7: return ImGuiKey_7;
|
||||
case NKCODE_8: return ImGuiKey_8;
|
||||
case NKCODE_9: return ImGuiKey_9;
|
||||
|
||||
// Letter keys
|
||||
case NKCODE_A: return ImGuiKey_A;
|
||||
case NKCODE_B: return ImGuiKey_B;
|
||||
case NKCODE_C: return ImGuiKey_C;
|
||||
case NKCODE_D: return ImGuiKey_D;
|
||||
case NKCODE_E: return ImGuiKey_E;
|
||||
case NKCODE_F: return ImGuiKey_F;
|
||||
case NKCODE_G: return ImGuiKey_G;
|
||||
case NKCODE_H: return ImGuiKey_H;
|
||||
case NKCODE_I: return ImGuiKey_I;
|
||||
case NKCODE_J: return ImGuiKey_J;
|
||||
case NKCODE_K: return ImGuiKey_K;
|
||||
case NKCODE_L: return ImGuiKey_L;
|
||||
case NKCODE_M: return ImGuiKey_M;
|
||||
case NKCODE_N: return ImGuiKey_N;
|
||||
case NKCODE_O: return ImGuiKey_O;
|
||||
case NKCODE_P: return ImGuiKey_P;
|
||||
case NKCODE_Q: return ImGuiKey_Q;
|
||||
case NKCODE_R: return ImGuiKey_R;
|
||||
case NKCODE_S: return ImGuiKey_S;
|
||||
case NKCODE_T: return ImGuiKey_T;
|
||||
case NKCODE_U: return ImGuiKey_U;
|
||||
case NKCODE_V: return ImGuiKey_V;
|
||||
case NKCODE_W: return ImGuiKey_W;
|
||||
case NKCODE_X: return ImGuiKey_X;
|
||||
case NKCODE_Y: return ImGuiKey_Y;
|
||||
case NKCODE_Z: return ImGuiKey_Z;
|
||||
|
||||
// Symbols
|
||||
case NKCODE_COMMA: return ImGuiKey_Comma;
|
||||
case NKCODE_PERIOD: return ImGuiKey_Period;
|
||||
case NKCODE_MINUS: return ImGuiKey_Minus;
|
||||
case NKCODE_EQUALS: return ImGuiKey_Equal;
|
||||
case NKCODE_LEFT_BRACKET: return ImGuiKey_LeftBracket;
|
||||
case NKCODE_RIGHT_BRACKET: return ImGuiKey_RightBracket;
|
||||
case NKCODE_BACKSLASH: return ImGuiKey_Backslash;
|
||||
case NKCODE_SEMICOLON: return ImGuiKey_Semicolon;
|
||||
case NKCODE_APOSTROPHE: return ImGuiKey_Apostrophe;
|
||||
case NKCODE_SLASH: return ImGuiKey_Slash;
|
||||
case NKCODE_GRAVE: return ImGuiKey_GraveAccent;
|
||||
|
||||
// Function keys
|
||||
case NKCODE_F1: return ImGuiKey_F1;
|
||||
case NKCODE_F2: return ImGuiKey_F2;
|
||||
case NKCODE_F3: return ImGuiKey_F3;
|
||||
case NKCODE_F4: return ImGuiKey_F4;
|
||||
case NKCODE_F5: return ImGuiKey_F5;
|
||||
case NKCODE_F6: return ImGuiKey_F6;
|
||||
case NKCODE_F7: return ImGuiKey_F7;
|
||||
case NKCODE_F8: return ImGuiKey_F8;
|
||||
case NKCODE_F9: return ImGuiKey_F9;
|
||||
case NKCODE_F10: return ImGuiKey_F10;
|
||||
case NKCODE_F11: return ImGuiKey_F11;
|
||||
case NKCODE_F12: return ImGuiKey_F12;
|
||||
|
||||
// Keypad
|
||||
case NKCODE_NUMPAD_0: return ImGuiKey_Keypad0;
|
||||
case NKCODE_NUMPAD_1: return ImGuiKey_Keypad1;
|
||||
case NKCODE_NUMPAD_2: return ImGuiKey_Keypad2;
|
||||
case NKCODE_NUMPAD_3: return ImGuiKey_Keypad3;
|
||||
case NKCODE_NUMPAD_4: return ImGuiKey_Keypad4;
|
||||
case NKCODE_NUMPAD_5: return ImGuiKey_Keypad5;
|
||||
case NKCODE_NUMPAD_6: return ImGuiKey_Keypad6;
|
||||
case NKCODE_NUMPAD_7: return ImGuiKey_Keypad7;
|
||||
case NKCODE_NUMPAD_8: return ImGuiKey_Keypad8;
|
||||
case NKCODE_NUMPAD_9: return ImGuiKey_Keypad9;
|
||||
case NKCODE_NUMPAD_DIVIDE: return ImGuiKey_KeypadDivide;
|
||||
case NKCODE_NUMPAD_MULTIPLY: return ImGuiKey_KeypadMultiply;
|
||||
case NKCODE_NUMPAD_SUBTRACT: return ImGuiKey_KeypadSubtract;
|
||||
case NKCODE_NUMPAD_ADD: return ImGuiKey_KeypadAdd;
|
||||
case NKCODE_NUMPAD_ENTER: return ImGuiKey_KeypadEnter;
|
||||
case NKCODE_NUMPAD_EQUALS: return ImGuiKey_KeypadEqual;
|
||||
|
||||
// Lock keys
|
||||
case NKCODE_NUM_LOCK: return ImGuiKey_NumLock;
|
||||
case NKCODE_SCROLL_LOCK: return ImGuiKey_ScrollLock;
|
||||
default: return ImGuiKey_None;
|
||||
}
|
||||
}
|
13
ext/imgui/imgui_impl_platform.h
Normal file
13
ext/imgui/imgui_impl_platform.h
Normal file
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "ext/imgui/imgui.h"
|
||||
#include "Common/Input/KeyCodes.h"
|
||||
#include "Common/Input/InputState.h"
|
||||
|
||||
ImGuiKey KeyCodeToImGui(InputKeyCode keyCode);
|
||||
|
||||
void ImGui_ImplPlatform_NewFrame();
|
||||
|
||||
void ImGui_ImplPlatform_KeyEvent(const KeyInput &key);
|
||||
void ImGui_ImplPlatform_TouchEvent(const TouchInput &touch);
|
||||
void ImGui_ImplPlatform_AxisEvent(const AxisInput &axis);
|
283
ext/imgui/imgui_impl_thin3d.cpp
Normal file
283
ext/imgui/imgui_impl_thin3d.cpp
Normal file
@ -0,0 +1,283 @@
|
||||
// dear imgui: Renderer Backend for PPSSPP's thin3d
|
||||
|
||||
#include "imgui.h"
|
||||
#include "imgui_impl_thin3d.h"
|
||||
#include <cstdio>
|
||||
|
||||
#include "Common/System/Display.h"
|
||||
#include "Common/Math/lin/matrix4x4.h"
|
||||
|
||||
// Forward Declarations
|
||||
bool ImGui_ImplThin3d_CreateDeviceObjects(Draw::DrawContext *draw);
|
||||
void ImGui_ImplThin3d_DestroyDeviceObjects(Draw::DrawContext *draw);
|
||||
|
||||
Lin::Matrix4x4 g_drawMatrix;
|
||||
|
||||
struct ImGui_ImplThin3d_Data {
|
||||
Draw::SamplerState *fontSampler = nullptr;
|
||||
Draw::Texture *fontImage = nullptr;
|
||||
Draw::Pipeline *pipeline = nullptr;
|
||||
};
|
||||
|
||||
// Backend data stored in io.BackendRendererUserData to allow support for multiple Dear ImGui contexts
|
||||
// It is STRONGLY preferred that you use docking branch with multi-viewports (== single Dear ImGui context + multiple windows) instead of multiple Dear ImGui contexts.
|
||||
// FIXME: multi-context support is not tested and probably dysfunctional in this backend.
|
||||
static ImGui_ImplThin3d_Data* ImGui_ImplThin3d_GetBackendData() {
|
||||
return ImGui::GetCurrentContext() ? (ImGui_ImplThin3d_Data *)ImGui::GetIO().BackendRendererUserData : nullptr;
|
||||
}
|
||||
|
||||
static void ImGui_ImplThin3d_SetupRenderState(Draw::DrawContext *draw, ImDrawData* draw_data, Draw::Pipeline *pipeline, int fb_width, int fb_height) {
|
||||
ImGui_ImplThin3d_Data* bd = ImGui_ImplThin3d_GetBackendData();
|
||||
|
||||
// Bind pipeline and texture
|
||||
draw->BindPipeline(pipeline);
|
||||
draw->BindTexture(0, bd->fontImage);
|
||||
draw->BindSamplerStates(0, 1, &bd->fontSampler);
|
||||
|
||||
// Setup viewport:
|
||||
{
|
||||
Draw::Viewport viewport;
|
||||
viewport.TopLeftX = 0;
|
||||
viewport.TopLeftY = 0;
|
||||
viewport.Width = (float)fb_width;
|
||||
viewport.Height = (float)fb_height;
|
||||
viewport.MinDepth = 0.0f;
|
||||
viewport.MaxDepth = 1.0f;
|
||||
draw->SetViewport(viewport);
|
||||
}
|
||||
|
||||
// Setup scale and translation:
|
||||
// Our visible imgui space lies from draw_data->DisplayPps (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps.
|
||||
// We currently ignore DisplayPos.
|
||||
{
|
||||
Lin::Matrix4x4 mtx = ComputeOrthoMatrix(draw_data->DisplaySize.x, draw_data->DisplaySize.y, draw->GetDeviceCaps().coordConvention);
|
||||
|
||||
Draw::VsTexColUB ub{};
|
||||
memcpy(ub.WorldViewProj, mtx.getReadPtr(), sizeof(Lin::Matrix4x4));
|
||||
ub.saturation = 1.0f;
|
||||
draw->UpdateDynamicUniformBuffer(&ub, sizeof(ub));
|
||||
}
|
||||
}
|
||||
|
||||
// Render function
|
||||
void ImGui_ImplThin3d_RenderDrawData(ImDrawData* draw_data, Draw::DrawContext *draw) {
|
||||
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
||||
int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
|
||||
int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y);
|
||||
if (fb_width <= 0 || fb_height <= 0)
|
||||
return;
|
||||
|
||||
ImGui_ImplThin3d_Data* bd = ImGui_ImplThin3d_GetBackendData();
|
||||
|
||||
// Setup desired Vulkan state
|
||||
ImGui_ImplThin3d_SetupRenderState(draw, draw_data, bd->pipeline, fb_width, fb_height);
|
||||
|
||||
// Will project scissor/clipping rectangles into framebuffer space
|
||||
ImVec2 clip_off = draw_data->DisplayPos; // (0,0) unless using multi-viewports
|
||||
ImVec2 clip_scale = draw_data->FramebufferScale; // (1,1) unless using retina display which are often (2,2)
|
||||
|
||||
_assert_(sizeof(ImDrawIdx) == 2);
|
||||
|
||||
std::vector<Draw::ClippedDraw> draws;
|
||||
// Render command lists
|
||||
for (int n = 0; n < draw_data->CmdListsCount; n++) {
|
||||
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
||||
draws.clear();
|
||||
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) {
|
||||
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
|
||||
if (pcmd->UserCallback != nullptr) {
|
||||
// User callback, registered via ImDrawList::AddCallback()
|
||||
// (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.)
|
||||
if (pcmd->UserCallback == ImDrawCallback_ResetRenderState) {
|
||||
ImGui_ImplThin3d_SetupRenderState(draw, draw_data, bd->pipeline, fb_width, fb_height);
|
||||
} else {
|
||||
pcmd->UserCallback(cmd_list, pcmd);
|
||||
}
|
||||
} else {
|
||||
// Project scissor/clipping rectangles into framebuffer space
|
||||
ImVec2 clip_min((pcmd->ClipRect.x - clip_off.x) * clip_scale.x, (pcmd->ClipRect.y - clip_off.y) * clip_scale.y);
|
||||
ImVec2 clip_max((pcmd->ClipRect.z - clip_off.x) * clip_scale.x, (pcmd->ClipRect.w - clip_off.y) * clip_scale.y);
|
||||
|
||||
// Clamp to viewport as vkCmdSetScissor() won't accept values that are off bounds
|
||||
if (clip_min.x < 0.0f) { clip_min.x = 0.0f; }
|
||||
if (clip_min.y < 0.0f) { clip_min.y = 0.0f; }
|
||||
if (clip_max.x > fb_width) { clip_max.x = (float)fb_width; }
|
||||
if (clip_max.y > fb_height) { clip_max.y = (float)fb_height; }
|
||||
if (clip_max.x <= clip_min.x || clip_max.y <= clip_min.y)
|
||||
continue;
|
||||
|
||||
Draw::ClippedDraw draw;
|
||||
draw.clipx = clip_min.x;
|
||||
draw.clipy = clip_min.y;
|
||||
draw.clipw = clip_max.x - clip_min.x;
|
||||
draw.cliph = clip_max.y - clip_min.y;
|
||||
draw.indexCount = pcmd->ElemCount;
|
||||
draw.indexOffset = pcmd->IdxOffset;
|
||||
draws.push_back(draw);
|
||||
}
|
||||
}
|
||||
draw->DrawIndexedClippedBatchUP(cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.size(), cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.size(), draws);
|
||||
}
|
||||
|
||||
draw->SetScissorRect(0, 0, fb_width, fb_height);
|
||||
}
|
||||
|
||||
bool ImGui_ImplThin3d_CreateFontsTexture(Draw::DrawContext *draw) {
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
ImGui_ImplThin3d_Data* bd = ImGui_ImplThin3d_GetBackendData();
|
||||
|
||||
// Destroy existing texture (if any)
|
||||
if (bd->fontImage) {
|
||||
ImGui_ImplThin3d_DestroyFontsTexture(draw);
|
||||
}
|
||||
|
||||
unsigned char* pixels;
|
||||
int width, height;
|
||||
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
|
||||
size_t upload_size = width * height * 4 * sizeof(char);
|
||||
|
||||
// Create the Image:
|
||||
{
|
||||
Draw::TextureDesc desc;
|
||||
desc.width = width;
|
||||
desc.height = height;
|
||||
desc.mipLevels = 1;
|
||||
desc.format = Draw::DataFormat::R8G8B8A8_UNORM;
|
||||
desc.type = Draw::TextureType::LINEAR2D;
|
||||
desc.depth = 1;
|
||||
desc.tag = "imgui-font";
|
||||
desc.initData.push_back((const uint8_t *)pixels);
|
||||
bd->fontImage = draw->CreateTexture(desc);
|
||||
}
|
||||
|
||||
// Store our identifier
|
||||
|
||||
io.Fonts->SetTexID((ImTextureID)bd->fontImage);
|
||||
return true;
|
||||
}
|
||||
|
||||
// You probably never need to call this, as it is called by ImGui_ImplThin3d_CreateFontsTexture() and ImGui_ImplThin3d_Shutdown().
|
||||
void ImGui_ImplThin3d_DestroyFontsTexture(Draw::DrawContext *draw) {
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
ImGui_ImplThin3d_Data* bd = ImGui_ImplThin3d_GetBackendData();
|
||||
if (bd->fontImage) {
|
||||
bd->fontImage->Release();
|
||||
io.Fonts->SetTexID(0);
|
||||
}
|
||||
}
|
||||
|
||||
static void ImGui_ImplThin3d_CreatePipeline(Draw::DrawContext *draw) {
|
||||
ImGui_ImplThin3d_Data* bd = ImGui_ImplThin3d_GetBackendData();
|
||||
|
||||
using namespace Draw;
|
||||
|
||||
static const Draw::InputLayoutDesc ilDesc = {
|
||||
sizeof(ImDrawVert),
|
||||
{
|
||||
{ SEM_POSITION, DataFormat::R32G32_FLOAT, offsetof(ImDrawVert, pos) },
|
||||
{ SEM_TEXCOORD0, DataFormat::R32G32_FLOAT, offsetof(ImDrawVert, uv) },
|
||||
{ SEM_COLOR0, DataFormat::R8G8B8A8_UNORM, offsetof(ImDrawVert, col) },
|
||||
},
|
||||
};
|
||||
InputLayout *inputLayout = draw->CreateInputLayout(ilDesc);
|
||||
|
||||
BlendState *blend = draw->CreateBlendState({ true, 0xF,
|
||||
BlendFactor::SRC_ALPHA, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendOp::ADD,
|
||||
BlendFactor::ONE, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendOp::ADD,
|
||||
});
|
||||
|
||||
DepthStencilStateDesc dsDesc{};
|
||||
DepthStencilState *depthStencil = draw->CreateDepthStencilState(dsDesc);
|
||||
RasterState *rasterNoCull = draw->CreateRasterState({});
|
||||
|
||||
ShaderModule *vs_texture_color_2d = draw->GetVshaderPreset(VS_TEXTURE_COLOR_2D);
|
||||
ShaderModule *fs_texture_color_2d = draw->GetFshaderPreset(FS_TEXTURE_COLOR_2D);
|
||||
|
||||
PipelineDesc pipelineDesc{
|
||||
Primitive::TRIANGLE_LIST,
|
||||
{ vs_texture_color_2d, fs_texture_color_2d },
|
||||
inputLayout,
|
||||
depthStencil,
|
||||
blend,
|
||||
rasterNoCull,
|
||||
&vsTexColBufDesc
|
||||
};
|
||||
|
||||
bd->pipeline = draw->CreateGraphicsPipeline(pipelineDesc, "imgui-pipeline");
|
||||
}
|
||||
|
||||
bool ImGui_ImplThin3d_CreateDeviceObjects(Draw::DrawContext *draw) {
|
||||
ImGui_ImplThin3d_Data* bd = ImGui_ImplThin3d_GetBackendData();
|
||||
|
||||
if (!bd->fontSampler) {
|
||||
// Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling.
|
||||
Draw::SamplerStateDesc desc{};
|
||||
desc.magFilter = Draw::TextureFilter::LINEAR;
|
||||
desc.minFilter = Draw::TextureFilter::LINEAR;
|
||||
desc.mipFilter = Draw::TextureFilter::NEAREST;
|
||||
desc.wrapU = Draw::TextureAddressMode::REPEAT;
|
||||
desc.wrapV = Draw::TextureAddressMode::REPEAT;
|
||||
desc.wrapW = Draw::TextureAddressMode::REPEAT;
|
||||
desc.maxAniso = 1.0f;
|
||||
bd->fontSampler = draw->CreateSamplerState(desc);
|
||||
}
|
||||
|
||||
ImGui_ImplThin3d_CreatePipeline(draw);
|
||||
ImGui_ImplThin3d_CreateFontsTexture(draw);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ImGui_ImplThin3d_DestroyDeviceObjects(Draw::DrawContext *draw) {
|
||||
ImGui_ImplThin3d_Data* bd = ImGui_ImplThin3d_GetBackendData();
|
||||
ImGui_ImplThin3d_DestroyFontsTexture(draw);
|
||||
bd->pipeline->Release();
|
||||
bd->pipeline = nullptr;
|
||||
bd->fontSampler->Release();
|
||||
bd->fontSampler = nullptr;
|
||||
}
|
||||
|
||||
bool ImGui_ImplThin3d_Init(Draw::DrawContext *draw) {
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
IMGUI_CHECKVERSION();
|
||||
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
||||
|
||||
// Setup backend capabilities flags
|
||||
ImGui_ImplThin3d_Data* bd = IM_NEW(ImGui_ImplThin3d_Data)();
|
||||
io.BackendRendererUserData = (void*)bd;
|
||||
io.BackendRendererName = "imgui_impl_thin3d";
|
||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||
ImGui_ImplThin3d_CreateDeviceObjects(draw);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ImGui_ImplThin3d_Shutdown(Draw::DrawContext *draw) {
|
||||
ImGui_ImplThin3d_Data* bd = ImGui_ImplThin3d_GetBackendData();
|
||||
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
|
||||
ImGui_ImplThin3d_DestroyDeviceObjects(draw);
|
||||
io.BackendRendererName = nullptr;
|
||||
io.BackendRendererUserData = nullptr;
|
||||
io.BackendFlags &= ~ImGuiBackendFlags_RendererHasVtxOffset;
|
||||
IM_DELETE(bd);
|
||||
}
|
||||
|
||||
void ImGui_ImplThin3d_NewFrame(Draw::DrawContext *draw, Lin::Matrix4x4 drawMatrix) {
|
||||
ImGui_ImplThin3d_Data* bd = ImGui_ImplThin3d_GetBackendData();
|
||||
IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplThin3d_Init()?");
|
||||
if (!bd->fontImage)
|
||||
ImGui_ImplThin3d_CreateFontsTexture(draw);
|
||||
g_drawMatrix = drawMatrix;
|
||||
}
|
||||
|
||||
// Register a texture. No-op.
|
||||
ImTextureID ImGui_ImplThin3d_AddTexture(Draw::Texture *texture) {
|
||||
ImGui_ImplThin3d_Data* bd = ImGui_ImplThin3d_GetBackendData();
|
||||
return (void *)texture;
|
||||
}
|
||||
|
||||
// Unregister a texture. No-op.
|
||||
Draw::Texture *ImGui_ImplThin3d_RemoveTexture(ImTextureID tex) {
|
||||
return (Draw::Texture *)tex;
|
||||
}
|
57
ext/imgui/imgui_impl_thin3d.h
Normal file
57
ext/imgui/imgui_impl_thin3d.h
Normal file
@ -0,0 +1,57 @@
|
||||
// dear imgui: Renderer Backend for Vulkan
|
||||
// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..)
|
||||
|
||||
// Implemented features:
|
||||
// [!] Renderer: User texture binding. Use 'VkDescriptorSet' as ImTextureID. Read the FAQ about ImTextureID! See https://github.com/ocornut/imgui/pull/914 for discussions.
|
||||
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
||||
|
||||
// Important: on 32-bit systems, user texture binding is only supported if your imconfig file has '#define ImTextureID ImU64'.
|
||||
// See imgui_impl_vulkan.cpp file for details.
|
||||
|
||||
// The aim of imgui_impl_vulkan.h/.cpp is to be usable in your engine without any modification.
|
||||
// IF YOU FEEL YOU NEED TO MAKE ANY CHANGE TO THIS CODE, please share them and your feedback at https://github.com/ocornut/imgui/
|
||||
|
||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||
// Learn about Dear ImGui:
|
||||
// - FAQ https://dearimgui.com/faq
|
||||
// - Getting Started https://dearimgui.com/getting-started
|
||||
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||
// - Introduction, links and more at the top of imgui.cpp
|
||||
|
||||
// Important note to the reader who wish to integrate imgui_impl_vulkan.cpp/.h in their own engine/app.
|
||||
// - Common ImGui_ImplThin3d_XXX functions and structures are used to interface with imgui_impl_vulkan.cpp/.h.
|
||||
// You will use those if you want to use this rendering backend in your engine/app.
|
||||
// - Helper ImGui_ImplThin3dH_XXX functions and structures are only used by this example (main.cpp) and by
|
||||
// the backend itself (imgui_impl_vulkan.cpp), but should PROBABLY NOT be used by your own engine/app code.
|
||||
// Read comments in imgui_impl_vulkan.h.
|
||||
|
||||
#pragma once
|
||||
#ifndef IMGUI_DISABLE
|
||||
#include "imgui.h" // IMGUI_IMPL_API
|
||||
|
||||
#include "Common/GPU/thin3d.h"
|
||||
#include "Common/Math/lin/matrix4x4.h"
|
||||
|
||||
// Called by user code
|
||||
IMGUI_IMPL_API bool ImGui_ImplThin3d_Init(Draw::DrawContext *draw);
|
||||
IMGUI_IMPL_API void ImGui_ImplThin3d_Shutdown(Draw::DrawContext *draw);
|
||||
IMGUI_IMPL_API void ImGui_ImplThin3d_NewFrame(Draw::DrawContext *draw, Lin::Matrix4x4 drawMatrix);
|
||||
IMGUI_IMPL_API void ImGui_ImplThin3d_RenderDrawData(ImDrawData* draw_data, Draw::DrawContext *draw);
|
||||
IMGUI_IMPL_API bool ImGui_ImplThin3d_CreateFontsTexture(Draw::DrawContext *draw);
|
||||
IMGUI_IMPL_API void ImGui_ImplThin3d_DestroyFontsTexture(Draw::DrawContext *draw);
|
||||
IMGUI_IMPL_API void ImGui_ImplThin3d_SetMinImageCount(uint32_t min_image_count); // To override MinImageCount after initialization (e.g. if swap chain is recreated)
|
||||
|
||||
IMGUI_IMPL_API ImTextureID ImGui_ImplThin3d_AddTexture(Draw::Texture *texture);
|
||||
IMGUI_IMPL_API Draw::Texture *ImGui_ImplThin3d_RemoveTexture(ImTextureID texture);
|
||||
|
||||
// Helper structure to hold the data needed by one rendering context into one OS window
|
||||
// (Used by example's main.cpp. Used by multi-viewport features. Probably NOT used by your own engine/app.)
|
||||
struct ImGui_ImplThin3dH_Window
|
||||
{
|
||||
int Width = 0;
|
||||
int Height = 0;
|
||||
bool ClearEnable = true;
|
||||
};
|
||||
|
||||
#endif // #ifndef IMGUI_DISABLE
|
3616
ext/imgui/imgui_internal.h
Normal file
3616
ext/imgui/imgui_internal.h
Normal file
File diff suppressed because it is too large
Load Diff
4450
ext/imgui/imgui_tables.cpp
Normal file
4450
ext/imgui/imgui_tables.cpp
Normal file
File diff suppressed because it is too large
Load Diff
9031
ext/imgui/imgui_widgets.cpp
Normal file
9031
ext/imgui/imgui_widgets.cpp
Normal file
File diff suppressed because it is too large
Load Diff
627
ext/imgui/imstb_rectpack.h
Normal file
627
ext/imgui/imstb_rectpack.h
Normal file
@ -0,0 +1,627 @@
|
||||
// [DEAR IMGUI]
|
||||
// This is a slightly modified version of stb_rect_pack.h 1.01.
|
||||
// Grep for [DEAR IMGUI] to find the changes.
|
||||
//
|
||||
// stb_rect_pack.h - v1.01 - public domain - rectangle packing
|
||||
// Sean Barrett 2014
|
||||
//
|
||||
// Useful for e.g. packing rectangular textures into an atlas.
|
||||
// Does not do rotation.
|
||||
//
|
||||
// Before #including,
|
||||
//
|
||||
// #define STB_RECT_PACK_IMPLEMENTATION
|
||||
//
|
||||
// in the file that you want to have the implementation.
|
||||
//
|
||||
// Not necessarily the awesomest packing method, but better than
|
||||
// the totally naive one in stb_truetype (which is primarily what
|
||||
// this is meant to replace).
|
||||
//
|
||||
// Has only had a few tests run, may have issues.
|
||||
//
|
||||
// More docs to come.
|
||||
//
|
||||
// No memory allocations; uses qsort() and assert() from stdlib.
|
||||
// Can override those by defining STBRP_SORT and STBRP_ASSERT.
|
||||
//
|
||||
// This library currently uses the Skyline Bottom-Left algorithm.
|
||||
//
|
||||
// Please note: better rectangle packers are welcome! Please
|
||||
// implement them to the same API, but with a different init
|
||||
// function.
|
||||
//
|
||||
// Credits
|
||||
//
|
||||
// Library
|
||||
// Sean Barrett
|
||||
// Minor features
|
||||
// Martins Mozeiko
|
||||
// github:IntellectualKitty
|
||||
//
|
||||
// Bugfixes / warning fixes
|
||||
// Jeremy Jaussaud
|
||||
// Fabian Giesen
|
||||
//
|
||||
// Version history:
|
||||
//
|
||||
// 1.01 (2021-07-11) always use large rect mode, expose STBRP__MAXVAL in public section
|
||||
// 1.00 (2019-02-25) avoid small space waste; gracefully fail too-wide rectangles
|
||||
// 0.99 (2019-02-07) warning fixes
|
||||
// 0.11 (2017-03-03) return packing success/fail result
|
||||
// 0.10 (2016-10-25) remove cast-away-const to avoid warnings
|
||||
// 0.09 (2016-08-27) fix compiler warnings
|
||||
// 0.08 (2015-09-13) really fix bug with empty rects (w=0 or h=0)
|
||||
// 0.07 (2015-09-13) fix bug with empty rects (w=0 or h=0)
|
||||
// 0.06 (2015-04-15) added STBRP_SORT to allow replacing qsort
|
||||
// 0.05: added STBRP_ASSERT to allow replacing assert
|
||||
// 0.04: fixed minor bug in STBRP_LARGE_RECTS support
|
||||
// 0.01: initial release
|
||||
//
|
||||
// LICENSE
|
||||
//
|
||||
// See end of file for license information.
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// INCLUDE SECTION
|
||||
//
|
||||
|
||||
#ifndef STB_INCLUDE_STB_RECT_PACK_H
|
||||
#define STB_INCLUDE_STB_RECT_PACK_H
|
||||
|
||||
#define STB_RECT_PACK_VERSION 1
|
||||
|
||||
#ifdef STBRP_STATIC
|
||||
#define STBRP_DEF static
|
||||
#else
|
||||
#define STBRP_DEF extern
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct stbrp_context stbrp_context;
|
||||
typedef struct stbrp_node stbrp_node;
|
||||
typedef struct stbrp_rect stbrp_rect;
|
||||
|
||||
typedef int stbrp_coord;
|
||||
|
||||
#define STBRP__MAXVAL 0x7fffffff
|
||||
// Mostly for internal use, but this is the maximum supported coordinate value.
|
||||
|
||||
STBRP_DEF int stbrp_pack_rects (stbrp_context *context, stbrp_rect *rects, int num_rects);
|
||||
// Assign packed locations to rectangles. The rectangles are of type
|
||||
// 'stbrp_rect' defined below, stored in the array 'rects', and there
|
||||
// are 'num_rects' many of them.
|
||||
//
|
||||
// Rectangles which are successfully packed have the 'was_packed' flag
|
||||
// set to a non-zero value and 'x' and 'y' store the minimum location
|
||||
// on each axis (i.e. bottom-left in cartesian coordinates, top-left
|
||||
// if you imagine y increasing downwards). Rectangles which do not fit
|
||||
// have the 'was_packed' flag set to 0.
|
||||
//
|
||||
// You should not try to access the 'rects' array from another thread
|
||||
// while this function is running, as the function temporarily reorders
|
||||
// the array while it executes.
|
||||
//
|
||||
// To pack into another rectangle, you need to call stbrp_init_target
|
||||
// again. To continue packing into the same rectangle, you can call
|
||||
// this function again. Calling this multiple times with multiple rect
|
||||
// arrays will probably produce worse packing results than calling it
|
||||
// a single time with the full rectangle array, but the option is
|
||||
// available.
|
||||
//
|
||||
// The function returns 1 if all of the rectangles were successfully
|
||||
// packed and 0 otherwise.
|
||||
|
||||
struct stbrp_rect
|
||||
{
|
||||
// reserved for your use:
|
||||
int id;
|
||||
|
||||
// input:
|
||||
stbrp_coord w, h;
|
||||
|
||||
// output:
|
||||
stbrp_coord x, y;
|
||||
int was_packed; // non-zero if valid packing
|
||||
|
||||
}; // 16 bytes, nominally
|
||||
|
||||
|
||||
STBRP_DEF void stbrp_init_target (stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes);
|
||||
// Initialize a rectangle packer to:
|
||||
// pack a rectangle that is 'width' by 'height' in dimensions
|
||||
// using temporary storage provided by the array 'nodes', which is 'num_nodes' long
|
||||
//
|
||||
// You must call this function every time you start packing into a new target.
|
||||
//
|
||||
// There is no "shutdown" function. The 'nodes' memory must stay valid for
|
||||
// the following stbrp_pack_rects() call (or calls), but can be freed after
|
||||
// the call (or calls) finish.
|
||||
//
|
||||
// Note: to guarantee best results, either:
|
||||
// 1. make sure 'num_nodes' >= 'width'
|
||||
// or 2. call stbrp_allow_out_of_mem() defined below with 'allow_out_of_mem = 1'
|
||||
//
|
||||
// If you don't do either of the above things, widths will be quantized to multiples
|
||||
// of small integers to guarantee the algorithm doesn't run out of temporary storage.
|
||||
//
|
||||
// If you do #2, then the non-quantized algorithm will be used, but the algorithm
|
||||
// may run out of temporary storage and be unable to pack some rectangles.
|
||||
|
||||
STBRP_DEF void stbrp_setup_allow_out_of_mem (stbrp_context *context, int allow_out_of_mem);
|
||||
// Optionally call this function after init but before doing any packing to
|
||||
// change the handling of the out-of-temp-memory scenario, described above.
|
||||
// If you call init again, this will be reset to the default (false).
|
||||
|
||||
|
||||
STBRP_DEF void stbrp_setup_heuristic (stbrp_context *context, int heuristic);
|
||||
// Optionally select which packing heuristic the library should use. Different
|
||||
// heuristics will produce better/worse results for different data sets.
|
||||
// If you call init again, this will be reset to the default.
|
||||
|
||||
enum
|
||||
{
|
||||
STBRP_HEURISTIC_Skyline_default=0,
|
||||
STBRP_HEURISTIC_Skyline_BL_sortHeight = STBRP_HEURISTIC_Skyline_default,
|
||||
STBRP_HEURISTIC_Skyline_BF_sortHeight
|
||||
};
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// the details of the following structures don't matter to you, but they must
|
||||
// be visible so you can handle the memory allocations for them
|
||||
|
||||
struct stbrp_node
|
||||
{
|
||||
stbrp_coord x,y;
|
||||
stbrp_node *next;
|
||||
};
|
||||
|
||||
struct stbrp_context
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
int align;
|
||||
int init_mode;
|
||||
int heuristic;
|
||||
int num_nodes;
|
||||
stbrp_node *active_head;
|
||||
stbrp_node *free_head;
|
||||
stbrp_node extra[2]; // we allocate two extra nodes so optimal user-node-count is 'width' not 'width+2'
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPLEMENTATION SECTION
|
||||
//
|
||||
|
||||
#ifdef STB_RECT_PACK_IMPLEMENTATION
|
||||
#ifndef STBRP_SORT
|
||||
#include <stdlib.h>
|
||||
#define STBRP_SORT qsort
|
||||
#endif
|
||||
|
||||
#ifndef STBRP_ASSERT
|
||||
#include <assert.h>
|
||||
#define STBRP_ASSERT assert
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define STBRP__NOTUSED(v) (void)(v)
|
||||
#define STBRP__CDECL __cdecl
|
||||
#else
|
||||
#define STBRP__NOTUSED(v) (void)sizeof(v)
|
||||
#define STBRP__CDECL
|
||||
#endif
|
||||
|
||||
enum
|
||||
{
|
||||
STBRP__INIT_skyline = 1
|
||||
};
|
||||
|
||||
STBRP_DEF void stbrp_setup_heuristic(stbrp_context *context, int heuristic)
|
||||
{
|
||||
switch (context->init_mode) {
|
||||
case STBRP__INIT_skyline:
|
||||
STBRP_ASSERT(heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight || heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight);
|
||||
context->heuristic = heuristic;
|
||||
break;
|
||||
default:
|
||||
STBRP_ASSERT(0);
|
||||
}
|
||||
}
|
||||
|
||||
STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context *context, int allow_out_of_mem)
|
||||
{
|
||||
if (allow_out_of_mem)
|
||||
// if it's ok to run out of memory, then don't bother aligning them;
|
||||
// this gives better packing, but may fail due to OOM (even though
|
||||
// the rectangles easily fit). @TODO a smarter approach would be to only
|
||||
// quantize once we've hit OOM, then we could get rid of this parameter.
|
||||
context->align = 1;
|
||||
else {
|
||||
// if it's not ok to run out of memory, then quantize the widths
|
||||
// so that num_nodes is always enough nodes.
|
||||
//
|
||||
// I.e. num_nodes * align >= width
|
||||
// align >= width / num_nodes
|
||||
// align = ceil(width/num_nodes)
|
||||
|
||||
context->align = (context->width + context->num_nodes-1) / context->num_nodes;
|
||||
}
|
||||
}
|
||||
|
||||
STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i < num_nodes-1; ++i)
|
||||
nodes[i].next = &nodes[i+1];
|
||||
nodes[i].next = NULL;
|
||||
context->init_mode = STBRP__INIT_skyline;
|
||||
context->heuristic = STBRP_HEURISTIC_Skyline_default;
|
||||
context->free_head = &nodes[0];
|
||||
context->active_head = &context->extra[0];
|
||||
context->width = width;
|
||||
context->height = height;
|
||||
context->num_nodes = num_nodes;
|
||||
stbrp_setup_allow_out_of_mem(context, 0);
|
||||
|
||||
// node 0 is the full width, node 1 is the sentinel (lets us not store width explicitly)
|
||||
context->extra[0].x = 0;
|
||||
context->extra[0].y = 0;
|
||||
context->extra[0].next = &context->extra[1];
|
||||
context->extra[1].x = (stbrp_coord) width;
|
||||
context->extra[1].y = (1<<30);
|
||||
context->extra[1].next = NULL;
|
||||
}
|
||||
|
||||
// find minimum y position if it starts at x1
|
||||
static int stbrp__skyline_find_min_y(stbrp_context *c, stbrp_node *first, int x0, int width, int *pwaste)
|
||||
{
|
||||
stbrp_node *node = first;
|
||||
int x1 = x0 + width;
|
||||
int min_y, visited_width, waste_area;
|
||||
|
||||
STBRP__NOTUSED(c);
|
||||
|
||||
STBRP_ASSERT(first->x <= x0);
|
||||
|
||||
#if 0
|
||||
// skip in case we're past the node
|
||||
while (node->next->x <= x0)
|
||||
++node;
|
||||
#else
|
||||
STBRP_ASSERT(node->next->x > x0); // we ended up handling this in the caller for efficiency
|
||||
#endif
|
||||
|
||||
STBRP_ASSERT(node->x <= x0);
|
||||
|
||||
min_y = 0;
|
||||
waste_area = 0;
|
||||
visited_width = 0;
|
||||
while (node->x < x1) {
|
||||
if (node->y > min_y) {
|
||||
// raise min_y higher.
|
||||
// we've accounted for all waste up to min_y,
|
||||
// but we'll now add more waste for everything we've visted
|
||||
waste_area += visited_width * (node->y - min_y);
|
||||
min_y = node->y;
|
||||
// the first time through, visited_width might be reduced
|
||||
if (node->x < x0)
|
||||
visited_width += node->next->x - x0;
|
||||
else
|
||||
visited_width += node->next->x - node->x;
|
||||
} else {
|
||||
// add waste area
|
||||
int under_width = node->next->x - node->x;
|
||||
if (under_width + visited_width > width)
|
||||
under_width = width - visited_width;
|
||||
waste_area += under_width * (min_y - node->y);
|
||||
visited_width += under_width;
|
||||
}
|
||||
node = node->next;
|
||||
}
|
||||
|
||||
*pwaste = waste_area;
|
||||
return min_y;
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int x,y;
|
||||
stbrp_node **prev_link;
|
||||
} stbrp__findresult;
|
||||
|
||||
static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int width, int height)
|
||||
{
|
||||
int best_waste = (1<<30), best_x, best_y = (1 << 30);
|
||||
stbrp__findresult fr;
|
||||
stbrp_node **prev, *node, *tail, **best = NULL;
|
||||
|
||||
// align to multiple of c->align
|
||||
width = (width + c->align - 1);
|
||||
width -= width % c->align;
|
||||
STBRP_ASSERT(width % c->align == 0);
|
||||
|
||||
// if it can't possibly fit, bail immediately
|
||||
if (width > c->width || height > c->height) {
|
||||
fr.prev_link = NULL;
|
||||
fr.x = fr.y = 0;
|
||||
return fr;
|
||||
}
|
||||
|
||||
node = c->active_head;
|
||||
prev = &c->active_head;
|
||||
while (node->x + width <= c->width) {
|
||||
int y,waste;
|
||||
y = stbrp__skyline_find_min_y(c, node, node->x, width, &waste);
|
||||
if (c->heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight) { // actually just want to test BL
|
||||
// bottom left
|
||||
if (y < best_y) {
|
||||
best_y = y;
|
||||
best = prev;
|
||||
}
|
||||
} else {
|
||||
// best-fit
|
||||
if (y + height <= c->height) {
|
||||
// can only use it if it first vertically
|
||||
if (y < best_y || (y == best_y && waste < best_waste)) {
|
||||
best_y = y;
|
||||
best_waste = waste;
|
||||
best = prev;
|
||||
}
|
||||
}
|
||||
}
|
||||
prev = &node->next;
|
||||
node = node->next;
|
||||
}
|
||||
|
||||
best_x = (best == NULL) ? 0 : (*best)->x;
|
||||
|
||||
// if doing best-fit (BF), we also have to try aligning right edge to each node position
|
||||
//
|
||||
// e.g, if fitting
|
||||
//
|
||||
// ____________________
|
||||
// |____________________|
|
||||
//
|
||||
// into
|
||||
//
|
||||
// | |
|
||||
// | ____________|
|
||||
// |____________|
|
||||
//
|
||||
// then right-aligned reduces waste, but bottom-left BL is always chooses left-aligned
|
||||
//
|
||||
// This makes BF take about 2x the time
|
||||
|
||||
if (c->heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight) {
|
||||
tail = c->active_head;
|
||||
node = c->active_head;
|
||||
prev = &c->active_head;
|
||||
// find first node that's admissible
|
||||
while (tail->x < width)
|
||||
tail = tail->next;
|
||||
while (tail) {
|
||||
int xpos = tail->x - width;
|
||||
int y,waste;
|
||||
STBRP_ASSERT(xpos >= 0);
|
||||
// find the left position that matches this
|
||||
while (node->next->x <= xpos) {
|
||||
prev = &node->next;
|
||||
node = node->next;
|
||||
}
|
||||
STBRP_ASSERT(node->next->x > xpos && node->x <= xpos);
|
||||
y = stbrp__skyline_find_min_y(c, node, xpos, width, &waste);
|
||||
if (y + height <= c->height) {
|
||||
if (y <= best_y) {
|
||||
if (y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x)) {
|
||||
best_x = xpos;
|
||||
//STBRP_ASSERT(y <= best_y); [DEAR IMGUI]
|
||||
best_y = y;
|
||||
best_waste = waste;
|
||||
best = prev;
|
||||
}
|
||||
}
|
||||
}
|
||||
tail = tail->next;
|
||||
}
|
||||
}
|
||||
|
||||
fr.prev_link = best;
|
||||
fr.x = best_x;
|
||||
fr.y = best_y;
|
||||
return fr;
|
||||
}
|
||||
|
||||
static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, int width, int height)
|
||||
{
|
||||
// find best position according to heuristic
|
||||
stbrp__findresult res = stbrp__skyline_find_best_pos(context, width, height);
|
||||
stbrp_node *node, *cur;
|
||||
|
||||
// bail if:
|
||||
// 1. it failed
|
||||
// 2. the best node doesn't fit (we don't always check this)
|
||||
// 3. we're out of memory
|
||||
if (res.prev_link == NULL || res.y + height > context->height || context->free_head == NULL) {
|
||||
res.prev_link = NULL;
|
||||
return res;
|
||||
}
|
||||
|
||||
// on success, create new node
|
||||
node = context->free_head;
|
||||
node->x = (stbrp_coord) res.x;
|
||||
node->y = (stbrp_coord) (res.y + height);
|
||||
|
||||
context->free_head = node->next;
|
||||
|
||||
// insert the new node into the right starting point, and
|
||||
// let 'cur' point to the remaining nodes needing to be
|
||||
// stiched back in
|
||||
|
||||
cur = *res.prev_link;
|
||||
if (cur->x < res.x) {
|
||||
// preserve the existing one, so start testing with the next one
|
||||
stbrp_node *next = cur->next;
|
||||
cur->next = node;
|
||||
cur = next;
|
||||
} else {
|
||||
*res.prev_link = node;
|
||||
}
|
||||
|
||||
// from here, traverse cur and free the nodes, until we get to one
|
||||
// that shouldn't be freed
|
||||
while (cur->next && cur->next->x <= res.x + width) {
|
||||
stbrp_node *next = cur->next;
|
||||
// move the current node to the free list
|
||||
cur->next = context->free_head;
|
||||
context->free_head = cur;
|
||||
cur = next;
|
||||
}
|
||||
|
||||
// stitch the list back in
|
||||
node->next = cur;
|
||||
|
||||
if (cur->x < res.x + width)
|
||||
cur->x = (stbrp_coord) (res.x + width);
|
||||
|
||||
#ifdef _DEBUG
|
||||
cur = context->active_head;
|
||||
while (cur->x < context->width) {
|
||||
STBRP_ASSERT(cur->x < cur->next->x);
|
||||
cur = cur->next;
|
||||
}
|
||||
STBRP_ASSERT(cur->next == NULL);
|
||||
|
||||
{
|
||||
int count=0;
|
||||
cur = context->active_head;
|
||||
while (cur) {
|
||||
cur = cur->next;
|
||||
++count;
|
||||
}
|
||||
cur = context->free_head;
|
||||
while (cur) {
|
||||
cur = cur->next;
|
||||
++count;
|
||||
}
|
||||
STBRP_ASSERT(count == context->num_nodes+2);
|
||||
}
|
||||
#endif
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static int STBRP__CDECL rect_height_compare(const void *a, const void *b)
|
||||
{
|
||||
const stbrp_rect *p = (const stbrp_rect *) a;
|
||||
const stbrp_rect *q = (const stbrp_rect *) b;
|
||||
if (p->h > q->h)
|
||||
return -1;
|
||||
if (p->h < q->h)
|
||||
return 1;
|
||||
return (p->w > q->w) ? -1 : (p->w < q->w);
|
||||
}
|
||||
|
||||
static int STBRP__CDECL rect_original_order(const void *a, const void *b)
|
||||
{
|
||||
const stbrp_rect *p = (const stbrp_rect *) a;
|
||||
const stbrp_rect *q = (const stbrp_rect *) b;
|
||||
return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed);
|
||||
}
|
||||
|
||||
STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects)
|
||||
{
|
||||
int i, all_rects_packed = 1;
|
||||
|
||||
// we use the 'was_packed' field internally to allow sorting/unsorting
|
||||
for (i=0; i < num_rects; ++i) {
|
||||
rects[i].was_packed = i;
|
||||
}
|
||||
|
||||
// sort according to heuristic
|
||||
STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_height_compare);
|
||||
|
||||
for (i=0; i < num_rects; ++i) {
|
||||
if (rects[i].w == 0 || rects[i].h == 0) {
|
||||
rects[i].x = rects[i].y = 0; // empty rect needs no space
|
||||
} else {
|
||||
stbrp__findresult fr = stbrp__skyline_pack_rectangle(context, rects[i].w, rects[i].h);
|
||||
if (fr.prev_link) {
|
||||
rects[i].x = (stbrp_coord) fr.x;
|
||||
rects[i].y = (stbrp_coord) fr.y;
|
||||
} else {
|
||||
rects[i].x = rects[i].y = STBRP__MAXVAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// unsort
|
||||
STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_original_order);
|
||||
|
||||
// set was_packed flags and all_rects_packed status
|
||||
for (i=0; i < num_rects; ++i) {
|
||||
rects[i].was_packed = !(rects[i].x == STBRP__MAXVAL && rects[i].y == STBRP__MAXVAL);
|
||||
if (!rects[i].was_packed)
|
||||
all_rects_packed = 0;
|
||||
}
|
||||
|
||||
// return the all_rects_packed status
|
||||
return all_rects_packed;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
------------------------------------------------------------------------------
|
||||
This software is available under 2 licenses -- choose whichever you prefer.
|
||||
------------------------------------------------------------------------------
|
||||
ALTERNATIVE A - MIT License
|
||||
Copyright (c) 2017 Sean Barrett
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
------------------------------------------------------------------------------
|
||||
ALTERNATIVE B - Public Domain (www.unlicense.org)
|
||||
This is free and unencumbered software released into the public domain.
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
|
||||
software, either in source code form or as a compiled binary, for any purpose,
|
||||
commercial or non-commercial, and by any means.
|
||||
In jurisdictions that recognize copyright laws, the author or authors of this
|
||||
software dedicate any and all copyright interest in the software to the public
|
||||
domain. We make this dedication for the benefit of the public at large and to
|
||||
the detriment of our heirs and successors. We intend this dedication to be an
|
||||
overt act of relinquishment in perpetuity of all present and future rights to
|
||||
this software under copyright law.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
------------------------------------------------------------------------------
|
||||
*/
|
1441
ext/imgui/imstb_textedit.h
Normal file
1441
ext/imgui/imstb_textedit.h
Normal file
File diff suppressed because it is too large
Load Diff
5085
ext/imgui/imstb_truetype.h
Normal file
5085
ext/imgui/imstb_truetype.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -326,6 +326,15 @@ SOURCES_CXX += $(EXTDIR)/cityhash/city.cpp
|
||||
SOURCES_CXX += \
|
||||
$(EXTDIR)/basis_universal/basisu_transcoder.cpp
|
||||
|
||||
SOURCES_CXX += \
|
||||
$(EXTDIR)/imgui/imgui.cpp \
|
||||
$(EXTDIR)/imgui/imgui_demo.cpp \
|
||||
$(EXTDIR)/imgui/imgui_draw.cpp \
|
||||
$(EXTDIR)/imgui/imgui_impl_thin3d.cpp \
|
||||
$(EXTDIR)/imgui/imgui_impl_platform.cpp \
|
||||
$(EXTDIR)/imgui/imgui_tables.cpp \
|
||||
$(EXTDIR)/imgui/imgui_widgets.cpp
|
||||
|
||||
SOURCES_CXX += \
|
||||
$(EXTDIR)/armips/Core/Types.cpp
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user