Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
Imgui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Silvio Roggentin
Imgui
Commits
08400f5b
Commit
08400f5b
authored
5 months ago
by
ocornut
Browse files
Options
Downloads
Patches
Plain Diff
Backends: DX12: tidying up, added a ImGui_ImplDX12_Texture helper struct.
parent
40b2286d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
backends/imgui_impl_dx12.cpp
+21
-13
21 additions, 13 deletions
backends/imgui_impl_dx12.cpp
with
21 additions
and
13 deletions
backends/imgui_impl_dx12.cpp
+
21
−
13
View file @
08400f5b
...
...
@@ -55,8 +55,16 @@
#pragma comment(lib, "d3dcompiler") // Automatically link with d3dcompiler.lib as we are using D3DCompile() below.
#endif
// DirectX data
// DirectX
12
data
struct
ImGui_ImplDX12_RenderBuffers
;
struct
ImGui_ImplDX12_Texture
{
ID3D12Resource
*
pTextureResource
;
D3D12_CPU_DESCRIPTOR_HANDLE
hFontSrvCpuDescHandle
;
D3D12_GPU_DESCRIPTOR_HANDLE
hFontSrvGpuDescHandle
;
};
struct
ImGui_ImplDX12_Data
{
ImGui_ImplDX12_InitInfo
InitInfo
;
...
...
@@ -64,9 +72,7 @@ struct ImGui_ImplDX12_Data
ID3D12RootSignature
*
pRootSignature
;
ID3D12PipelineState
*
pPipelineState
;
DXGI_FORMAT
RTVFormat
;
ID3D12Resource
*
pFontTextureResource
;
D3D12_CPU_DESCRIPTOR_HANDLE
hFontSrvCpuDescHandle
;
D3D12_GPU_DESCRIPTOR_HANDLE
hFontSrvGpuDescHandle
;
ImGui_ImplDX12_Texture
FontTexture
;
ID3D12DescriptorHeap
*
pd3dSrvDescHeap
;
UINT
numFramesInFlight
;
...
...
@@ -316,6 +322,7 @@ static void ImGui_ImplDX12_CreateFontsTexture()
io
.
Fonts
->
GetTexDataAsRGBA32
(
&
pixels
,
&
width
,
&
height
);
// Upload texture to graphics system
ImGui_ImplDX12_Texture
*
font_tex
=
&
bd
->
FontTexture
;
{
D3D12_HEAP_PROPERTIES
props
;
memset
(
&
props
,
0
,
sizeof
(
D3D12_HEAP_PROPERTIES
));
...
...
@@ -446,13 +453,13 @@ static void ImGui_ImplDX12_CreateFontsTexture()
srvDesc
.
Texture2D
.
MipLevels
=
desc
.
MipLevels
;
srvDesc
.
Texture2D
.
MostDetailedMip
=
0
;
srvDesc
.
Shader4ComponentMapping
=
D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING
;
bd
->
pd3dDevice
->
CreateShaderResourceView
(
pTexture
,
&
srvDesc
,
bd
->
hFontSrvCpuDescHandle
);
SafeRelease
(
bd
->
pFont
TextureResource
);
bd
->
pFont
TextureResource
=
pTexture
;
bd
->
pd3dDevice
->
CreateShaderResourceView
(
pTexture
,
&
srvDesc
,
font_tex
->
hFontSrvCpuDescHandle
);
SafeRelease
(
font_tex
->
p
TextureResource
);
font_tex
->
p
TextureResource
=
pTexture
;
}
// Store our identifier
io
.
Fonts
->
SetTexID
((
ImTextureID
)
bd
->
hFontSrvGpuDescHandle
.
ptr
);
io
.
Fonts
->
SetTexID
((
ImTextureID
)
font_tex
->
hFontSrvGpuDescHandle
.
ptr
);
}
bool
ImGui_ImplDX12_CreateDeviceObjects
()
...
...
@@ -700,11 +707,12 @@ void ImGui_ImplDX12_InvalidateDeviceObjects()
SafeRelease
(
bd
->
pPipelineState
);
// Free SRV descriptor used by texture
ImGui_ImplDX12_Texture
*
font_tex
=
&
bd
->
FontTexture
;
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
if
(
bd
->
InitInfo
.
SrvDescriptorFreeFn
!=
NULL
)
#endif
bd
->
InitInfo
.
SrvDescriptorFreeFn
(
&
bd
->
InitInfo
,
bd
->
hFontSrvCpuDescHandle
,
bd
->
hFontSrvGpuDescHandle
);
SafeRelease
(
bd
->
pFont
TextureResource
);
bd
->
InitInfo
.
SrvDescriptorFreeFn
(
&
bd
->
InitInfo
,
font_tex
->
hFontSrvCpuDescHandle
,
font_tex
->
hFontSrvGpuDescHandle
);
SafeRelease
(
font_tex
->
p
TextureResource
);
io
.
Fonts
->
SetTexID
(
0
);
// We copied bd->hFontSrvGpuDescHandle to io.Fonts->TexID so let's clear that as well.
for
(
UINT
i
=
0
;
i
<
bd
->
numFramesInFlight
;
i
++
)
...
...
@@ -738,14 +746,14 @@ bool ImGui_ImplDX12_Init(ImGui_ImplDX12_InitInfo* init_info)
if
(
init_info
->
SrvDescriptorAllocFn
!=
NULL
)
{
IM_ASSERT
(
init_info
->
SrvDescriptorFreeFn
!=
NULL
);
init_info
->
SrvDescriptorAllocFn
(
&
bd
->
InitInfo
,
&
bd
->
hFontSrvCpuDescHandle
,
&
bd
->
hFontSrvGpuDescHandle
);
init_info
->
SrvDescriptorAllocFn
(
&
bd
->
InitInfo
,
&
bd
->
FontTexture
.
hFontSrvCpuDescHandle
,
&
bd
->
FontTexture
.
hFontSrvGpuDescHandle
);
}
else
{
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
IM_ASSERT
(
init_info
->
LegacySingleSrvCpuDescriptor
.
ptr
!=
0
&&
init_info
->
LegacySingleSrvGpuDescriptor
.
ptr
!=
0
);
bd
->
hFontSrvCpuDescHandle
=
init_info
->
LegacySingleSrvCpuDescriptor
;
bd
->
hFontSrvGpuDescHandle
=
init_info
->
LegacySingleSrvGpuDescriptor
;
bd
->
FontTexture
.
hFontSrvCpuDescHandle
=
init_info
->
LegacySingleSrvCpuDescriptor
;
bd
->
FontTexture
.
hFontSrvGpuDescHandle
=
init_info
->
LegacySingleSrvGpuDescriptor
;
#else
IM_ASSERT
(
init_info
->
SrvDescriptorAllocFn
!=
NULL
);
IM_ASSERT
(
init_info
->
SrvDescriptorFreeFn
!=
NULL
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment