mirror of
https://github.com/ocornut/imgui.git
synced 2025-10-26 12:27:30 +00:00
Misc shallow tweaks/tidying up. (#8446)
This commit is contained in:
@@ -87,8 +87,7 @@ static void ImGui_ImplDX10_SetupRenderState(ImDrawData* draw_data, ID3D10Device*
|
|||||||
ImGui_ImplDX10_Data* bd = ImGui_ImplDX10_GetBackendData();
|
ImGui_ImplDX10_Data* bd = ImGui_ImplDX10_GetBackendData();
|
||||||
|
|
||||||
// Setup viewport
|
// Setup viewport
|
||||||
D3D10_VIEWPORT vp;
|
D3D10_VIEWPORT vp = {};
|
||||||
memset(&vp, 0, sizeof(D3D10_VIEWPORT));
|
|
||||||
vp.Width = (UINT)draw_data->DisplaySize.x;
|
vp.Width = (UINT)draw_data->DisplaySize.x;
|
||||||
vp.Height = (UINT)draw_data->DisplaySize.y;
|
vp.Height = (UINT)draw_data->DisplaySize.y;
|
||||||
vp.MinDepth = 0.0f;
|
vp.MinDepth = 0.0f;
|
||||||
@@ -152,8 +151,7 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
|
|||||||
{
|
{
|
||||||
if (bd->pVB) { bd->pVB->Release(); bd->pVB = nullptr; }
|
if (bd->pVB) { bd->pVB->Release(); bd->pVB = nullptr; }
|
||||||
bd->VertexBufferSize = draw_data->TotalVtxCount + 5000;
|
bd->VertexBufferSize = draw_data->TotalVtxCount + 5000;
|
||||||
D3D10_BUFFER_DESC desc;
|
D3D10_BUFFER_DESC desc = {};
|
||||||
memset(&desc, 0, sizeof(D3D10_BUFFER_DESC));
|
|
||||||
desc.Usage = D3D10_USAGE_DYNAMIC;
|
desc.Usage = D3D10_USAGE_DYNAMIC;
|
||||||
desc.ByteWidth = bd->VertexBufferSize * sizeof(ImDrawVert);
|
desc.ByteWidth = bd->VertexBufferSize * sizeof(ImDrawVert);
|
||||||
desc.BindFlags = D3D10_BIND_VERTEX_BUFFER;
|
desc.BindFlags = D3D10_BIND_VERTEX_BUFFER;
|
||||||
@@ -167,8 +165,7 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
|
|||||||
{
|
{
|
||||||
if (bd->pIB) { bd->pIB->Release(); bd->pIB = nullptr; }
|
if (bd->pIB) { bd->pIB->Release(); bd->pIB = nullptr; }
|
||||||
bd->IndexBufferSize = draw_data->TotalIdxCount + 10000;
|
bd->IndexBufferSize = draw_data->TotalIdxCount + 10000;
|
||||||
D3D10_BUFFER_DESC desc;
|
D3D10_BUFFER_DESC desc = {};
|
||||||
memset(&desc, 0, sizeof(D3D10_BUFFER_DESC));
|
|
||||||
desc.Usage = D3D10_USAGE_DYNAMIC;
|
desc.Usage = D3D10_USAGE_DYNAMIC;
|
||||||
desc.ByteWidth = bd->IndexBufferSize * sizeof(ImDrawIdx);
|
desc.ByteWidth = bd->IndexBufferSize * sizeof(ImDrawIdx);
|
||||||
desc.BindFlags = D3D10_BIND_INDEX_BUFFER;
|
desc.BindFlags = D3D10_BIND_INDEX_BUFFER;
|
||||||
@@ -431,7 +428,7 @@ bool ImGui_ImplDX10_CreateDeviceObjects()
|
|||||||
|
|
||||||
// Create the constant buffer
|
// Create the constant buffer
|
||||||
{
|
{
|
||||||
D3D10_BUFFER_DESC desc;
|
D3D10_BUFFER_DESC desc = {};
|
||||||
desc.ByteWidth = sizeof(VERTEX_CONSTANT_BUFFER_DX10);
|
desc.ByteWidth = sizeof(VERTEX_CONSTANT_BUFFER_DX10);
|
||||||
desc.Usage = D3D10_USAGE_DYNAMIC;
|
desc.Usage = D3D10_USAGE_DYNAMIC;
|
||||||
desc.BindFlags = D3D10_BIND_CONSTANT_BUFFER;
|
desc.BindFlags = D3D10_BIND_CONSTANT_BUFFER;
|
||||||
|
|||||||
@@ -90,8 +90,7 @@ static void ImGui_ImplDX11_SetupRenderState(ImDrawData* draw_data, ID3D11DeviceC
|
|||||||
ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData();
|
ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData();
|
||||||
|
|
||||||
// Setup viewport
|
// Setup viewport
|
||||||
D3D11_VIEWPORT vp;
|
D3D11_VIEWPORT vp = {};
|
||||||
memset(&vp, 0, sizeof(D3D11_VIEWPORT));
|
|
||||||
vp.Width = draw_data->DisplaySize.x;
|
vp.Width = draw_data->DisplaySize.x;
|
||||||
vp.Height = draw_data->DisplaySize.y;
|
vp.Height = draw_data->DisplaySize.y;
|
||||||
vp.MinDepth = 0.0f;
|
vp.MinDepth = 0.0f;
|
||||||
@@ -158,8 +157,7 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
|
|||||||
{
|
{
|
||||||
if (bd->pVB) { bd->pVB->Release(); bd->pVB = nullptr; }
|
if (bd->pVB) { bd->pVB->Release(); bd->pVB = nullptr; }
|
||||||
bd->VertexBufferSize = draw_data->TotalVtxCount + 5000;
|
bd->VertexBufferSize = draw_data->TotalVtxCount + 5000;
|
||||||
D3D11_BUFFER_DESC desc;
|
D3D11_BUFFER_DESC desc = {};
|
||||||
memset(&desc, 0, sizeof(D3D11_BUFFER_DESC));
|
|
||||||
desc.Usage = D3D11_USAGE_DYNAMIC;
|
desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||||
desc.ByteWidth = bd->VertexBufferSize * sizeof(ImDrawVert);
|
desc.ByteWidth = bd->VertexBufferSize * sizeof(ImDrawVert);
|
||||||
desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
||||||
@@ -172,8 +170,7 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
|
|||||||
{
|
{
|
||||||
if (bd->pIB) { bd->pIB->Release(); bd->pIB = nullptr; }
|
if (bd->pIB) { bd->pIB->Release(); bd->pIB = nullptr; }
|
||||||
bd->IndexBufferSize = draw_data->TotalIdxCount + 10000;
|
bd->IndexBufferSize = draw_data->TotalIdxCount + 10000;
|
||||||
D3D11_BUFFER_DESC desc;
|
D3D11_BUFFER_DESC desc = {};
|
||||||
memset(&desc, 0, sizeof(D3D11_BUFFER_DESC));
|
|
||||||
desc.Usage = D3D11_USAGE_DYNAMIC;
|
desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||||
desc.ByteWidth = bd->IndexBufferSize * sizeof(ImDrawIdx);
|
desc.ByteWidth = bd->IndexBufferSize * sizeof(ImDrawIdx);
|
||||||
desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
|
desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
|
||||||
@@ -447,7 +444,7 @@ bool ImGui_ImplDX11_CreateDeviceObjects()
|
|||||||
|
|
||||||
// Create the constant buffer
|
// Create the constant buffer
|
||||||
{
|
{
|
||||||
D3D11_BUFFER_DESC desc;
|
D3D11_BUFFER_DESC desc = {};
|
||||||
desc.ByteWidth = sizeof(VERTEX_CONSTANT_BUFFER_DX11);
|
desc.ByteWidth = sizeof(VERTEX_CONSTANT_BUFFER_DX11);
|
||||||
desc.Usage = D3D11_USAGE_DYNAMIC;
|
desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||||
desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
|
desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
|
||||||
|
|||||||
@@ -137,8 +137,7 @@ static void ImGui_ImplDX12_SetupRenderState(ImDrawData* draw_data, ID3D12Graphic
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Setup viewport
|
// Setup viewport
|
||||||
D3D12_VIEWPORT vp;
|
D3D12_VIEWPORT vp = {};
|
||||||
memset(&vp, 0, sizeof(D3D12_VIEWPORT));
|
|
||||||
vp.Width = draw_data->DisplaySize.x;
|
vp.Width = draw_data->DisplaySize.x;
|
||||||
vp.Height = draw_data->DisplaySize.y;
|
vp.Height = draw_data->DisplaySize.y;
|
||||||
vp.MinDepth = 0.0f;
|
vp.MinDepth = 0.0f;
|
||||||
@@ -149,14 +148,12 @@ static void ImGui_ImplDX12_SetupRenderState(ImDrawData* draw_data, ID3D12Graphic
|
|||||||
// Bind shader and vertex buffers
|
// Bind shader and vertex buffers
|
||||||
unsigned int stride = sizeof(ImDrawVert);
|
unsigned int stride = sizeof(ImDrawVert);
|
||||||
unsigned int offset = 0;
|
unsigned int offset = 0;
|
||||||
D3D12_VERTEX_BUFFER_VIEW vbv;
|
D3D12_VERTEX_BUFFER_VIEW vbv = {};
|
||||||
memset(&vbv, 0, sizeof(D3D12_VERTEX_BUFFER_VIEW));
|
|
||||||
vbv.BufferLocation = fr->VertexBuffer->GetGPUVirtualAddress() + offset;
|
vbv.BufferLocation = fr->VertexBuffer->GetGPUVirtualAddress() + offset;
|
||||||
vbv.SizeInBytes = fr->VertexBufferSize * stride;
|
vbv.SizeInBytes = fr->VertexBufferSize * stride;
|
||||||
vbv.StrideInBytes = stride;
|
vbv.StrideInBytes = stride;
|
||||||
command_list->IASetVertexBuffers(0, 1, &vbv);
|
command_list->IASetVertexBuffers(0, 1, &vbv);
|
||||||
D3D12_INDEX_BUFFER_VIEW ibv;
|
D3D12_INDEX_BUFFER_VIEW ibv = {};
|
||||||
memset(&ibv, 0, sizeof(D3D12_INDEX_BUFFER_VIEW));
|
|
||||||
ibv.BufferLocation = fr->IndexBuffer->GetGPUVirtualAddress();
|
ibv.BufferLocation = fr->IndexBuffer->GetGPUVirtualAddress();
|
||||||
ibv.SizeInBytes = fr->IndexBufferSize * sizeof(ImDrawIdx);
|
ibv.SizeInBytes = fr->IndexBufferSize * sizeof(ImDrawIdx);
|
||||||
ibv.Format = sizeof(ImDrawIdx) == 2 ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R32_UINT;
|
ibv.Format = sizeof(ImDrawIdx) == 2 ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R32_UINT;
|
||||||
@@ -196,13 +193,11 @@ void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandL
|
|||||||
{
|
{
|
||||||
SafeRelease(fr->VertexBuffer);
|
SafeRelease(fr->VertexBuffer);
|
||||||
fr->VertexBufferSize = draw_data->TotalVtxCount + 5000;
|
fr->VertexBufferSize = draw_data->TotalVtxCount + 5000;
|
||||||
D3D12_HEAP_PROPERTIES props;
|
D3D12_HEAP_PROPERTIES props = {};
|
||||||
memset(&props, 0, sizeof(D3D12_HEAP_PROPERTIES));
|
|
||||||
props.Type = D3D12_HEAP_TYPE_UPLOAD;
|
props.Type = D3D12_HEAP_TYPE_UPLOAD;
|
||||||
props.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN;
|
props.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN;
|
||||||
props.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN;
|
props.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN;
|
||||||
D3D12_RESOURCE_DESC desc;
|
D3D12_RESOURCE_DESC desc = {};
|
||||||
memset(&desc, 0, sizeof(D3D12_RESOURCE_DESC));
|
|
||||||
desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
|
desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
|
||||||
desc.Width = fr->VertexBufferSize * sizeof(ImDrawVert);
|
desc.Width = fr->VertexBufferSize * sizeof(ImDrawVert);
|
||||||
desc.Height = 1;
|
desc.Height = 1;
|
||||||
@@ -219,13 +214,11 @@ void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandL
|
|||||||
{
|
{
|
||||||
SafeRelease(fr->IndexBuffer);
|
SafeRelease(fr->IndexBuffer);
|
||||||
fr->IndexBufferSize = draw_data->TotalIdxCount + 10000;
|
fr->IndexBufferSize = draw_data->TotalIdxCount + 10000;
|
||||||
D3D12_HEAP_PROPERTIES props;
|
D3D12_HEAP_PROPERTIES props = {};
|
||||||
memset(&props, 0, sizeof(D3D12_HEAP_PROPERTIES));
|
|
||||||
props.Type = D3D12_HEAP_TYPE_UPLOAD;
|
props.Type = D3D12_HEAP_TYPE_UPLOAD;
|
||||||
props.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN;
|
props.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN;
|
||||||
props.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN;
|
props.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN;
|
||||||
D3D12_RESOURCE_DESC desc;
|
D3D12_RESOURCE_DESC desc = {};
|
||||||
memset(&desc, 0, sizeof(D3D12_RESOURCE_DESC));
|
|
||||||
desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
|
desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
|
||||||
desc.Width = fr->IndexBufferSize * sizeof(ImDrawIdx);
|
desc.Width = fr->IndexBufferSize * sizeof(ImDrawIdx);
|
||||||
desc.Height = 1;
|
desc.Height = 1;
|
||||||
@@ -333,8 +326,7 @@ static void ImGui_ImplDX12_CreateFontsTexture()
|
|||||||
// Upload texture to graphics system
|
// Upload texture to graphics system
|
||||||
ImGui_ImplDX12_Texture* font_tex = &bd->FontTexture;
|
ImGui_ImplDX12_Texture* font_tex = &bd->FontTexture;
|
||||||
{
|
{
|
||||||
D3D12_HEAP_PROPERTIES props;
|
D3D12_HEAP_PROPERTIES props = {};
|
||||||
memset(&props, 0, sizeof(D3D12_HEAP_PROPERTIES));
|
|
||||||
props.Type = D3D12_HEAP_TYPE_DEFAULT;
|
props.Type = D3D12_HEAP_TYPE_DEFAULT;
|
||||||
props.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN;
|
props.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN;
|
||||||
props.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN;
|
props.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN;
|
||||||
@@ -561,8 +553,7 @@ bool ImGui_ImplDX12_CreateDeviceObjects()
|
|||||||
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
|
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
|
||||||
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
|
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
|
||||||
|
|
||||||
D3D12_GRAPHICS_PIPELINE_STATE_DESC psoDesc;
|
D3D12_GRAPHICS_PIPELINE_STATE_DESC psoDesc = {};
|
||||||
memset(&psoDesc, 0, sizeof(D3D12_GRAPHICS_PIPELINE_STATE_DESC));
|
|
||||||
psoDesc.NodeMask = 1;
|
psoDesc.NodeMask = 1;
|
||||||
psoDesc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
|
psoDesc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
|
||||||
psoDesc.pRootSignature = bd->pRootSignature;
|
psoDesc.pRootSignature = bd->pRootSignature;
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
// - Introduction, links and more at the top of imgui.cpp
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
|
#pragma once
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
#ifndef IMGUI_DISABLE
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
|
|||||||
@@ -284,7 +284,7 @@ bool ImGui_ImplOpenGL3_InitLoader()
|
|||||||
{
|
{
|
||||||
// Initialize our loader
|
// Initialize our loader
|
||||||
#ifdef IMGUI_IMPL_OPENGL_LOADER_IMGL3W
|
#ifdef IMGUI_IMPL_OPENGL_LOADER_IMGL3W
|
||||||
if (glGetIntegerv == NULL && imgl3wInit() != 0)
|
if (glGetIntegerv == nullptr && imgl3wInit() != 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to initialize OpenGL loader!\n");
|
fprintf(stderr, "Failed to initialize OpenGL loader!\n");
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
// - Introduction, links and more at the top of imgui.cpp
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
|
#pragma once
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
#ifndef IMGUI_DISABLE
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user