mirror of
https://github.com/ocornut/imgui.git
synced 2026-02-02 01:54:30 +00:00
Backends: DirectX10, DirectX11, SDLGPU3: added nearest sampler in ImGui_ImplDX10_RenderState/ImGui_ImplDX11_RenderState/ImGui_ImplSDLGPU3_RenderState struct.
(#6969, #5834, #7468, #3590, #9173, #8926, #7230, #5118, #3590, #2973, #6969)
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2026-01-19: DirectX11: Added 'SamplerNearest' in ImGui_ImplDX11_RenderState. Renamed 'SamplerDefault' to 'SamplerLinear'.
|
||||||
// 2025-09-18: Call platform_io.ClearRendererHandlers() on shutdown.
|
// 2025-09-18: Call platform_io.ClearRendererHandlers() on shutdown.
|
||||||
// 2025-06-11: DirectX10: Added support for ImGuiBackendFlags_RendererHasTextures, for dynamic font atlas.
|
// 2025-06-11: DirectX10: Added support for ImGuiBackendFlags_RendererHasTextures, for dynamic font atlas.
|
||||||
// 2025-05-07: DirectX10: Honor draw_data->FramebufferScale to allow for custom backends and experiment using it (consistently with other renderer backends, even though in normal condition it is not set under Windows).
|
// 2025-05-07: DirectX10: Honor draw_data->FramebufferScale to allow for custom backends and experiment using it (consistently with other renderer backends, even though in normal condition it is not set under Windows).
|
||||||
@@ -75,6 +76,7 @@ struct ImGui_ImplDX10_Data
|
|||||||
ID3D10Buffer* pVertexConstantBuffer;
|
ID3D10Buffer* pVertexConstantBuffer;
|
||||||
ID3D10PixelShader* pPixelShader;
|
ID3D10PixelShader* pPixelShader;
|
||||||
ID3D10SamplerState* pTexSamplerLinear;
|
ID3D10SamplerState* pTexSamplerLinear;
|
||||||
|
ID3D10SamplerState* pTexSamplerNearest;
|
||||||
ID3D10RasterizerState* pRasterizerState;
|
ID3D10RasterizerState* pRasterizerState;
|
||||||
ID3D10BlendState* pBlendState;
|
ID3D10BlendState* pBlendState;
|
||||||
ID3D10DepthStencilState* pDepthStencilState;
|
ID3D10DepthStencilState* pDepthStencilState;
|
||||||
@@ -258,7 +260,8 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
|
|||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
ImGui_ImplDX10_RenderState render_state;
|
ImGui_ImplDX10_RenderState render_state;
|
||||||
render_state.Device = bd->pd3dDevice;
|
render_state.Device = bd->pd3dDevice;
|
||||||
render_state.SamplerDefault = bd->pTexSamplerLinear;
|
render_state.SamplerLinear = bd->pTexSamplerLinear;
|
||||||
|
render_state.SamplerNearest = bd->pTexSamplerNearest;
|
||||||
render_state.VertexConstantBuffer = bd->pVertexConstantBuffer;
|
render_state.VertexConstantBuffer = bd->pVertexConstantBuffer;
|
||||||
platform_io.Renderer_RenderState = &render_state;
|
platform_io.Renderer_RenderState = &render_state;
|
||||||
|
|
||||||
@@ -565,6 +568,8 @@ bool ImGui_ImplDX10_CreateDeviceObjects()
|
|||||||
desc.MinLOD = 0.f;
|
desc.MinLOD = 0.f;
|
||||||
desc.MaxLOD = 0.f;
|
desc.MaxLOD = 0.f;
|
||||||
bd->pd3dDevice->CreateSamplerState(&desc, &bd->pTexSamplerLinear);
|
bd->pd3dDevice->CreateSamplerState(&desc, &bd->pTexSamplerLinear);
|
||||||
|
desc.Filter = D3D10_FILTER_MIN_MAG_MIP_POINT;
|
||||||
|
bd->pd3dDevice->CreateSamplerState(&desc, &bd->pTexSamplerNearest);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -581,6 +586,7 @@ void ImGui_ImplDX10_InvalidateDeviceObjects()
|
|||||||
if (tex->RefCount == 1)
|
if (tex->RefCount == 1)
|
||||||
ImGui_ImplDX10_DestroyTexture(tex);
|
ImGui_ImplDX10_DestroyTexture(tex);
|
||||||
if (bd->pTexSamplerLinear) { bd->pTexSamplerLinear->Release(); bd->pTexSamplerLinear = nullptr; }
|
if (bd->pTexSamplerLinear) { bd->pTexSamplerLinear->Release(); bd->pTexSamplerLinear = nullptr; }
|
||||||
|
if (bd->pTexSamplerNearest) { bd->pTexSamplerNearest->Release(); bd->pTexSamplerNearest = nullptr; }
|
||||||
if (bd->pIB) { bd->pIB->Release(); bd->pIB = nullptr; }
|
if (bd->pIB) { bd->pIB->Release(); bd->pIB = nullptr; }
|
||||||
if (bd->pVB) { bd->pVB->Release(); bd->pVB = nullptr; }
|
if (bd->pVB) { bd->pVB->Release(); bd->pVB = nullptr; }
|
||||||
if (bd->pBlendState) { bd->pBlendState->Release(); bd->pBlendState = nullptr; }
|
if (bd->pBlendState) { bd->pBlendState->Release(); bd->pBlendState = nullptr; }
|
||||||
|
|||||||
@@ -41,7 +41,8 @@ IMGUI_IMPL_API void ImGui_ImplDX10_UpdateTexture(ImTextureData* tex);
|
|||||||
struct ImGui_ImplDX10_RenderState
|
struct ImGui_ImplDX10_RenderState
|
||||||
{
|
{
|
||||||
ID3D10Device* Device;
|
ID3D10Device* Device;
|
||||||
ID3D10SamplerState* SamplerDefault;
|
ID3D10SamplerState* SamplerLinear;
|
||||||
|
ID3D10SamplerState* SamplerNearest;
|
||||||
ID3D10Buffer* VertexConstantBuffer;
|
ID3D10Buffer* VertexConstantBuffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2026-01-19: DirectX11: Added 'SamplerNearest' in ImGui_ImplDX11_RenderState. Renamed 'SamplerDefault' to 'SamplerLinear'.
|
||||||
// 2025-09-18: Call platform_io.ClearRendererHandlers() on shutdown.
|
// 2025-09-18: Call platform_io.ClearRendererHandlers() on shutdown.
|
||||||
// 2025-06-11: DirectX11: Added support for ImGuiBackendFlags_RendererHasTextures, for dynamic font atlas.
|
// 2025-06-11: DirectX11: Added support for ImGuiBackendFlags_RendererHasTextures, for dynamic font atlas.
|
||||||
// 2025-05-07: DirectX11: Honor draw_data->FramebufferScale to allow for custom backends and experiment using it (consistently with other renderer backends, even though in normal condition it is not set under Windows).
|
// 2025-05-07: DirectX11: Honor draw_data->FramebufferScale to allow for custom backends and experiment using it (consistently with other renderer backends, even though in normal condition it is not set under Windows).
|
||||||
@@ -78,6 +79,7 @@ struct ImGui_ImplDX11_Data
|
|||||||
ID3D11Buffer* pVertexConstantBuffer;
|
ID3D11Buffer* pVertexConstantBuffer;
|
||||||
ID3D11PixelShader* pPixelShader;
|
ID3D11PixelShader* pPixelShader;
|
||||||
ID3D11SamplerState* pTexSamplerLinear;
|
ID3D11SamplerState* pTexSamplerLinear;
|
||||||
|
ID3D11SamplerState* pTexSamplerNearest;
|
||||||
ID3D11RasterizerState* pRasterizerState;
|
ID3D11RasterizerState* pRasterizerState;
|
||||||
ID3D11BlendState* pBlendState;
|
ID3D11BlendState* pBlendState;
|
||||||
ID3D11DepthStencilState* pDepthStencilState;
|
ID3D11DepthStencilState* pDepthStencilState;
|
||||||
@@ -272,7 +274,8 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
|
|||||||
ImGui_ImplDX11_RenderState render_state;
|
ImGui_ImplDX11_RenderState render_state;
|
||||||
render_state.Device = bd->pd3dDevice;
|
render_state.Device = bd->pd3dDevice;
|
||||||
render_state.DeviceContext = bd->pd3dDeviceContext;
|
render_state.DeviceContext = bd->pd3dDeviceContext;
|
||||||
render_state.SamplerDefault = bd->pTexSamplerLinear;
|
render_state.SamplerLinear = bd->pTexSamplerLinear;
|
||||||
|
render_state.SamplerNearest = bd->pTexSamplerNearest;
|
||||||
render_state.VertexConstantBuffer = bd->pVertexConstantBuffer;
|
render_state.VertexConstantBuffer = bd->pVertexConstantBuffer;
|
||||||
platform_io.Renderer_RenderState = &render_state;
|
platform_io.Renderer_RenderState = &render_state;
|
||||||
|
|
||||||
@@ -580,6 +583,8 @@ bool ImGui_ImplDX11_CreateDeviceObjects()
|
|||||||
desc.MinLOD = 0.f;
|
desc.MinLOD = 0.f;
|
||||||
desc.MaxLOD = 0.f;
|
desc.MaxLOD = 0.f;
|
||||||
bd->pd3dDevice->CreateSamplerState(&desc, &bd->pTexSamplerLinear);
|
bd->pd3dDevice->CreateSamplerState(&desc, &bd->pTexSamplerLinear);
|
||||||
|
desc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
|
||||||
|
bd->pd3dDevice->CreateSamplerState(&desc, &bd->pTexSamplerNearest);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -597,6 +602,7 @@ void ImGui_ImplDX11_InvalidateDeviceObjects()
|
|||||||
ImGui_ImplDX11_DestroyTexture(tex);
|
ImGui_ImplDX11_DestroyTexture(tex);
|
||||||
|
|
||||||
if (bd->pTexSamplerLinear) { bd->pTexSamplerLinear->Release(); bd->pTexSamplerLinear = nullptr; }
|
if (bd->pTexSamplerLinear) { bd->pTexSamplerLinear->Release(); bd->pTexSamplerLinear = nullptr; }
|
||||||
|
if (bd->pTexSamplerNearest) { bd->pTexSamplerNearest->Release(); bd->pTexSamplerNearest = nullptr; }
|
||||||
if (bd->pIB) { bd->pIB->Release(); bd->pIB = nullptr; }
|
if (bd->pIB) { bd->pIB->Release(); bd->pIB = nullptr; }
|
||||||
if (bd->pVB) { bd->pVB->Release(); bd->pVB = nullptr; }
|
if (bd->pVB) { bd->pVB->Release(); bd->pVB = nullptr; }
|
||||||
if (bd->pBlendState) { bd->pBlendState->Release(); bd->pBlendState = nullptr; }
|
if (bd->pBlendState) { bd->pBlendState->Release(); bd->pBlendState = nullptr; }
|
||||||
|
|||||||
@@ -44,7 +44,8 @@ struct ImGui_ImplDX11_RenderState
|
|||||||
{
|
{
|
||||||
ID3D11Device* Device;
|
ID3D11Device* Device;
|
||||||
ID3D11DeviceContext* DeviceContext;
|
ID3D11DeviceContext* DeviceContext;
|
||||||
ID3D11SamplerState* SamplerDefault;
|
ID3D11SamplerState* SamplerLinear;
|
||||||
|
ID3D11SamplerState* SamplerNearest;
|
||||||
ID3D11Buffer* VertexConstantBuffer;
|
ID3D11Buffer* VertexConstantBuffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ struct ImGui_ImplSDLGPU3_Data
|
|||||||
SDL_GPUShader* FragmentShader = nullptr;
|
SDL_GPUShader* FragmentShader = nullptr;
|
||||||
SDL_GPUGraphicsPipeline* Pipeline = nullptr;
|
SDL_GPUGraphicsPipeline* Pipeline = nullptr;
|
||||||
SDL_GPUSampler* TexSamplerLinear = nullptr;
|
SDL_GPUSampler* TexSamplerLinear = nullptr;
|
||||||
|
SDL_GPUSampler* TexSamplerNearest = nullptr;
|
||||||
SDL_GPUTransferBuffer* TexTransferBuffer = nullptr;
|
SDL_GPUTransferBuffer* TexTransferBuffer = nullptr;
|
||||||
uint32_t TexTransferBufferSize = 0;
|
uint32_t TexTransferBufferSize = 0;
|
||||||
|
|
||||||
@@ -236,7 +237,8 @@ void ImGui_ImplSDLGPU3_RenderDrawData(ImDrawData* draw_data, SDL_GPUCommandBuffe
|
|||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
ImGui_ImplSDLGPU3_RenderState render_state;
|
ImGui_ImplSDLGPU3_RenderState render_state;
|
||||||
render_state.Device = bd->InitInfo.Device;
|
render_state.Device = bd->InitInfo.Device;
|
||||||
render_state.SamplerDefault = render_state.SamplerCurrent = bd->TexSamplerLinear;
|
render_state.SamplerLinear = render_state.SamplerCurrent = bd->TexSamplerLinear;
|
||||||
|
render_state.SamplerNearest = bd->TexSamplerNearest;
|
||||||
platform_io.Renderer_RenderState = &render_state;
|
platform_io.Renderer_RenderState = &render_state;
|
||||||
|
|
||||||
ImGui_ImplSDLGPU3_SetupRenderState(draw_data, &render_state, pipeline, command_buffer, render_pass, fd, fb_width, fb_height);
|
ImGui_ImplSDLGPU3_SetupRenderState(draw_data, &render_state, pipeline, command_buffer, render_pass, fd, fb_width, fb_height);
|
||||||
@@ -592,9 +594,14 @@ void ImGui_ImplSDLGPU3_CreateDeviceObjects()
|
|||||||
sampler_info.enable_anisotropy = false;
|
sampler_info.enable_anisotropy = false;
|
||||||
sampler_info.max_anisotropy = 1.0f;
|
sampler_info.max_anisotropy = 1.0f;
|
||||||
sampler_info.enable_compare = false;
|
sampler_info.enable_compare = false;
|
||||||
|
|
||||||
bd->TexSamplerLinear = SDL_CreateGPUSampler(v->Device, &sampler_info);
|
bd->TexSamplerLinear = SDL_CreateGPUSampler(v->Device, &sampler_info);
|
||||||
IM_ASSERT(bd->TexSamplerLinear != nullptr && "Failed to create sampler, call SDL_GetError() for more information");
|
IM_ASSERT(bd->TexSamplerLinear != nullptr && "Failed to create sampler, call SDL_GetError() for more information");
|
||||||
|
|
||||||
|
sampler_info.min_filter = SDL_GPU_FILTER_NEAREST;
|
||||||
|
sampler_info.mag_filter = SDL_GPU_FILTER_NEAREST;
|
||||||
|
sampler_info.mipmap_mode = SDL_GPU_SAMPLERMIPMAPMODE_NEAREST;
|
||||||
|
bd->TexSamplerNearest = SDL_CreateGPUSampler(v->Device, &sampler_info);
|
||||||
|
IM_ASSERT(bd->TexSamplerNearest != nullptr && "Failed to create sampler, call SDL_GetError() for more information");
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui_ImplSDLGPU3_CreateGraphicsPipeline();
|
ImGui_ImplSDLGPU3_CreateGraphicsPipeline();
|
||||||
|
|||||||
@@ -57,7 +57,8 @@ IMGUI_IMPL_API void ImGui_ImplSDLGPU3_UpdateTexture(ImTextureData* tex);
|
|||||||
struct ImGui_ImplSDLGPU3_RenderState
|
struct ImGui_ImplSDLGPU3_RenderState
|
||||||
{
|
{
|
||||||
SDL_GPUDevice* Device;
|
SDL_GPUDevice* Device;
|
||||||
SDL_GPUSampler* SamplerDefault; // Default sampler (bilinear filtering)
|
SDL_GPUSampler* SamplerLinear; // Bilinear filtering sampler
|
||||||
|
SDL_GPUSampler* SamplerNearest; // Nearest/point filtering sampler
|
||||||
SDL_GPUSampler* SamplerCurrent; // Current sampler (may be changed by callback)
|
SDL_GPUSampler* SamplerCurrent; // Current sampler (may be changed by callback)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -190,6 +190,10 @@ Other Changes:
|
|||||||
non-ASCII values to io.AddInputCharacter(). (#9099)
|
non-ASCII values to io.AddInputCharacter(). (#9099)
|
||||||
- Debug Log: can output to debugger on Windows. (#5855)
|
- Debug Log: can output to debugger on Windows. (#5855)
|
||||||
- Backends:
|
- Backends:
|
||||||
|
- DirectX10: added 'SamplerNearest' in ImGui_ImplDX10_RenderState.
|
||||||
|
(+renamed 'SamplerDefault' to 'SamplerLinear', which was tagged as beta API)
|
||||||
|
- DirectX11: added 'SamplerNearest' in ImGui_ImplDX11_RenderState.
|
||||||
|
(+renamed 'SamplerDefault' to 'SamplerLinear', which was tagged as beta API)
|
||||||
- GLFW: Avoid repeated glfwSetCursor()/glfwSetInputMode() calls when unnecessary.
|
- GLFW: Avoid repeated glfwSetCursor()/glfwSetInputMode() calls when unnecessary.
|
||||||
Lowers overhead for very high framerates (e.g. 10k+ FPS). [@maxliani]
|
Lowers overhead for very high framerates (e.g. 10k+ FPS). [@maxliani]
|
||||||
- GLFW: Added IMGUI_IMPL_GLFW_DISABLE_X11 / IMGUI_IMPL_GLFW_DISABLE_WAYLAND to
|
- GLFW: Added IMGUI_IMPL_GLFW_DISABLE_X11 / IMGUI_IMPL_GLFW_DISABLE_WAYLAND to
|
||||||
@@ -198,6 +202,7 @@ Other Changes:
|
|||||||
platforms. (#8792, #9112)
|
platforms. (#8792, #9112)
|
||||||
- SDL2, SDL3: changed GetClipboardText() handler to return NULL on error aka
|
- SDL2, SDL3: changed GetClipboardText() handler to return NULL on error aka
|
||||||
clipboard contents is not text. Consistent with other backends. (#9168)
|
clipboard contents is not text. Consistent with other backends. (#9168)
|
||||||
|
- SDL_GPU3: added 'TexSamplerNearest' in ImGui_ImplSDLGPU3_RenderState.
|
||||||
- SDL_GPU3: macOS version can use MSL shaders in order to support macOS 10.14+
|
- SDL_GPU3: macOS version can use MSL shaders in order to support macOS 10.14+
|
||||||
(vs Metallib shaders requiring macOS 14+). Requires application calling
|
(vs Metallib shaders requiring macOS 14+). Requires application calling
|
||||||
SDL_CreateGPUDevice() with SDL_GPU_SHADERFORMAT_MSL. (#9076) [@Niminem]
|
SDL_CreateGPUDevice() with SDL_GPU_SHADERFORMAT_MSL. (#9076) [@Niminem]
|
||||||
|
|||||||
Reference in New Issue
Block a user