|
@@ -4,6 +4,7 @@
|
|
// Implemented features:
|
|
// Implemented features:
|
|
// [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID!
|
|
// [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID!
|
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
|
|
|
+// [X] Renderer: Expose selected render state for draw callbacks to use. Access in '(ImGui_ImplXXXX_RenderState*)platform_io.BackendRendererRenderState'.
|
|
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
|
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
|
|
|
|
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
|
@@ -17,6 +18,8 @@
|
|
// 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)
|
|
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
|
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
|
|
|
+// 2024-10-07: DirectX11: Changed default texture sampler to Clamp instead of Repeat/Wrap.
|
|
|
|
+// 2024-10-07: DirectX11: Expose selected render state in ImGui_ImplDX11_RenderState, which you can access in 'void* platform_io.Renderer_RenderState' during draw callbacks.
|
|
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
|
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
|
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
|
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
|
// 2021-05-19: DirectX11: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement)
|
|
// 2021-05-19: DirectX11: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement)
|
|
@@ -87,7 +90,7 @@ static void ImGui_ImplDX11_InitPlatformInterface();
|
|
static void ImGui_ImplDX11_ShutdownPlatformInterface();
|
|
static void ImGui_ImplDX11_ShutdownPlatformInterface();
|
|
|
|
|
|
// Functions
|
|
// Functions
|
|
-static void ImGui_ImplDX11_SetupRenderState(ImDrawData* draw_data, ID3D11DeviceContext* ctx)
|
|
|
|
|
|
+static void ImGui_ImplDX11_SetupRenderState(ImDrawData* draw_data, ID3D11DeviceContext* device_ctx)
|
|
{
|
|
{
|
|
ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData();
|
|
ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData();
|
|
|
|
|
|
@@ -99,29 +102,29 @@ static void ImGui_ImplDX11_SetupRenderState(ImDrawData* draw_data, ID3D11DeviceC
|
|
vp.MinDepth = 0.0f;
|
|
vp.MinDepth = 0.0f;
|
|
vp.MaxDepth = 1.0f;
|
|
vp.MaxDepth = 1.0f;
|
|
vp.TopLeftX = vp.TopLeftY = 0;
|
|
vp.TopLeftX = vp.TopLeftY = 0;
|
|
- ctx->RSSetViewports(1, &vp);
|
|
|
|
|
|
+ device_ctx->RSSetViewports(1, &vp);
|
|
|
|
|
|
// Setup shader and vertex buffers
|
|
// Setup shader and vertex buffers
|
|
unsigned int stride = sizeof(ImDrawVert);
|
|
unsigned int stride = sizeof(ImDrawVert);
|
|
unsigned int offset = 0;
|
|
unsigned int offset = 0;
|
|
- ctx->IASetInputLayout(bd->pInputLayout);
|
|
|
|
- ctx->IASetVertexBuffers(0, 1, &bd->pVB, &stride, &offset);
|
|
|
|
- ctx->IASetIndexBuffer(bd->pIB, sizeof(ImDrawIdx) == 2 ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R32_UINT, 0);
|
|
|
|
- ctx->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
|
|
|
- ctx->VSSetShader(bd->pVertexShader, nullptr, 0);
|
|
|
|
- ctx->VSSetConstantBuffers(0, 1, &bd->pVertexConstantBuffer);
|
|
|
|
- ctx->PSSetShader(bd->pPixelShader, nullptr, 0);
|
|
|
|
- ctx->PSSetSamplers(0, 1, &bd->pFontSampler);
|
|
|
|
- ctx->GSSetShader(nullptr, nullptr, 0);
|
|
|
|
- ctx->HSSetShader(nullptr, nullptr, 0); // In theory we should backup and restore this as well.. very infrequently used..
|
|
|
|
- ctx->DSSetShader(nullptr, nullptr, 0); // In theory we should backup and restore this as well.. very infrequently used..
|
|
|
|
- ctx->CSSetShader(nullptr, nullptr, 0); // In theory we should backup and restore this as well.. very infrequently used..
|
|
|
|
|
|
+ device_ctx->IASetInputLayout(bd->pInputLayout);
|
|
|
|
+ device_ctx->IASetVertexBuffers(0, 1, &bd->pVB, &stride, &offset);
|
|
|
|
+ device_ctx->IASetIndexBuffer(bd->pIB, sizeof(ImDrawIdx) == 2 ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R32_UINT, 0);
|
|
|
|
+ device_ctx->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
|
|
|
+ device_ctx->VSSetShader(bd->pVertexShader, nullptr, 0);
|
|
|
|
+ device_ctx->VSSetConstantBuffers(0, 1, &bd->pVertexConstantBuffer);
|
|
|
|
+ device_ctx->PSSetShader(bd->pPixelShader, nullptr, 0);
|
|
|
|
+ device_ctx->PSSetSamplers(0, 1, &bd->pFontSampler);
|
|
|
|
+ device_ctx->GSSetShader(nullptr, nullptr, 0);
|
|
|
|
+ device_ctx->HSSetShader(nullptr, nullptr, 0); // In theory we should backup and restore this as well.. very infrequently used..
|
|
|
|
+ device_ctx->DSSetShader(nullptr, nullptr, 0); // In theory we should backup and restore this as well.. very infrequently used..
|
|
|
|
+ device_ctx->CSSetShader(nullptr, nullptr, 0); // In theory we should backup and restore this as well.. very infrequently used..
|
|
|
|
|
|
// Setup blend state
|
|
// Setup blend state
|
|
const float blend_factor[4] = { 0.f, 0.f, 0.f, 0.f };
|
|
const float blend_factor[4] = { 0.f, 0.f, 0.f, 0.f };
|
|
- ctx->OMSetBlendState(bd->pBlendState, blend_factor, 0xffffffff);
|
|
|
|
- ctx->OMSetDepthStencilState(bd->pDepthStencilState, 0);
|
|
|
|
- ctx->RSSetState(bd->pRasterizerState);
|
|
|
|
|
|
+ device_ctx->OMSetBlendState(bd->pBlendState, blend_factor, 0xffffffff);
|
|
|
|
+ device_ctx->OMSetDepthStencilState(bd->pDepthStencilState, 0);
|
|
|
|
+ device_ctx->RSSetState(bd->pRasterizerState);
|
|
}
|
|
}
|
|
|
|
|
|
// Render function
|
|
// Render function
|
|
@@ -132,7 +135,7 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
|
|
return;
|
|
return;
|
|
|
|
|
|
ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData();
|
|
ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData();
|
|
- ID3D11DeviceContext* ctx = bd->pd3dDeviceContext;
|
|
|
|
|
|
+ ID3D11DeviceContext* device = bd->pd3dDeviceContext;
|
|
|
|
|
|
// Create and grow vertex/index buffers if needed
|
|
// Create and grow vertex/index buffers if needed
|
|
if (!bd->pVB || bd->VertexBufferSize < draw_data->TotalVtxCount)
|
|
if (!bd->pVB || bd->VertexBufferSize < draw_data->TotalVtxCount)
|
|
@@ -165,28 +168,28 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
|
|
|
|
|
|
// Upload vertex/index data into a single contiguous GPU buffer
|
|
// Upload vertex/index data into a single contiguous GPU buffer
|
|
D3D11_MAPPED_SUBRESOURCE vtx_resource, idx_resource;
|
|
D3D11_MAPPED_SUBRESOURCE vtx_resource, idx_resource;
|
|
- if (ctx->Map(bd->pVB, 0, D3D11_MAP_WRITE_DISCARD, 0, &vtx_resource) != S_OK)
|
|
|
|
|
|
+ if (device->Map(bd->pVB, 0, D3D11_MAP_WRITE_DISCARD, 0, &vtx_resource) != S_OK)
|
|
return;
|
|
return;
|
|
- if (ctx->Map(bd->pIB, 0, D3D11_MAP_WRITE_DISCARD, 0, &idx_resource) != S_OK)
|
|
|
|
|
|
+ if (device->Map(bd->pIB, 0, D3D11_MAP_WRITE_DISCARD, 0, &idx_resource) != S_OK)
|
|
return;
|
|
return;
|
|
ImDrawVert* vtx_dst = (ImDrawVert*)vtx_resource.pData;
|
|
ImDrawVert* vtx_dst = (ImDrawVert*)vtx_resource.pData;
|
|
ImDrawIdx* idx_dst = (ImDrawIdx*)idx_resource.pData;
|
|
ImDrawIdx* idx_dst = (ImDrawIdx*)idx_resource.pData;
|
|
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
|
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
|
{
|
|
{
|
|
- const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
|
|
|
- memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
|
|
|
|
- memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
|
|
|
|
- vtx_dst += cmd_list->VtxBuffer.Size;
|
|
|
|
- idx_dst += cmd_list->IdxBuffer.Size;
|
|
|
|
|
|
+ const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
|
|
+ memcpy(vtx_dst, draw_list->VtxBuffer.Data, draw_list->VtxBuffer.Size * sizeof(ImDrawVert));
|
|
|
|
+ memcpy(idx_dst, draw_list->IdxBuffer.Data, draw_list->IdxBuffer.Size * sizeof(ImDrawIdx));
|
|
|
|
+ vtx_dst += draw_list->VtxBuffer.Size;
|
|
|
|
+ idx_dst += draw_list->IdxBuffer.Size;
|
|
}
|
|
}
|
|
- ctx->Unmap(bd->pVB, 0);
|
|
|
|
- ctx->Unmap(bd->pIB, 0);
|
|
|
|
|
|
+ device->Unmap(bd->pVB, 0);
|
|
|
|
+ device->Unmap(bd->pIB, 0);
|
|
|
|
|
|
// Setup orthographic projection matrix into our constant buffer
|
|
// Setup orthographic projection matrix into our constant buffer
|
|
// Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps.
|
|
// Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps.
|
|
{
|
|
{
|
|
D3D11_MAPPED_SUBRESOURCE mapped_resource;
|
|
D3D11_MAPPED_SUBRESOURCE mapped_resource;
|
|
- if (ctx->Map(bd->pVertexConstantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped_resource) != S_OK)
|
|
|
|
|
|
+ if (device->Map(bd->pVertexConstantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped_resource) != S_OK)
|
|
return;
|
|
return;
|
|
VERTEX_CONSTANT_BUFFER_DX11* constant_buffer = (VERTEX_CONSTANT_BUFFER_DX11*)mapped_resource.pData;
|
|
VERTEX_CONSTANT_BUFFER_DX11* constant_buffer = (VERTEX_CONSTANT_BUFFER_DX11*)mapped_resource.pData;
|
|
float L = draw_data->DisplayPos.x;
|
|
float L = draw_data->DisplayPos.x;
|
|
@@ -201,7 +204,7 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
|
|
{ (R+L)/(L-R), (T+B)/(B-T), 0.5f, 1.0f },
|
|
{ (R+L)/(L-R), (T+B)/(B-T), 0.5f, 1.0f },
|
|
};
|
|
};
|
|
memcpy(&constant_buffer->mvp, mvp, sizeof(mvp));
|
|
memcpy(&constant_buffer->mvp, mvp, sizeof(mvp));
|
|
- ctx->Unmap(bd->pVertexConstantBuffer, 0);
|
|
|
|
|
|
+ device->Unmap(bd->pVertexConstantBuffer, 0);
|
|
}
|
|
}
|
|
|
|
|
|
// Backup DX state that will be modified to restore it afterwards (unfortunately this is very ugly looking and verbose. Close your eyes!)
|
|
// Backup DX state that will be modified to restore it afterwards (unfortunately this is very ugly looking and verbose. Close your eyes!)
|
|
@@ -231,26 +234,34 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
|
|
};
|
|
};
|
|
BACKUP_DX11_STATE old = {};
|
|
BACKUP_DX11_STATE old = {};
|
|
old.ScissorRectsCount = old.ViewportsCount = D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE;
|
|
old.ScissorRectsCount = old.ViewportsCount = D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE;
|
|
- ctx->RSGetScissorRects(&old.ScissorRectsCount, old.ScissorRects);
|
|
|
|
- ctx->RSGetViewports(&old.ViewportsCount, old.Viewports);
|
|
|
|
- ctx->RSGetState(&old.RS);
|
|
|
|
- ctx->OMGetBlendState(&old.BlendState, old.BlendFactor, &old.SampleMask);
|
|
|
|
- ctx->OMGetDepthStencilState(&old.DepthStencilState, &old.StencilRef);
|
|
|
|
- ctx->PSGetShaderResources(0, 1, &old.PSShaderResource);
|
|
|
|
- ctx->PSGetSamplers(0, 1, &old.PSSampler);
|
|
|
|
|
|
+ device->RSGetScissorRects(&old.ScissorRectsCount, old.ScissorRects);
|
|
|
|
+ device->RSGetViewports(&old.ViewportsCount, old.Viewports);
|
|
|
|
+ device->RSGetState(&old.RS);
|
|
|
|
+ device->OMGetBlendState(&old.BlendState, old.BlendFactor, &old.SampleMask);
|
|
|
|
+ device->OMGetDepthStencilState(&old.DepthStencilState, &old.StencilRef);
|
|
|
|
+ device->PSGetShaderResources(0, 1, &old.PSShaderResource);
|
|
|
|
+ device->PSGetSamplers(0, 1, &old.PSSampler);
|
|
old.PSInstancesCount = old.VSInstancesCount = old.GSInstancesCount = 256;
|
|
old.PSInstancesCount = old.VSInstancesCount = old.GSInstancesCount = 256;
|
|
- ctx->PSGetShader(&old.PS, old.PSInstances, &old.PSInstancesCount);
|
|
|
|
- ctx->VSGetShader(&old.VS, old.VSInstances, &old.VSInstancesCount);
|
|
|
|
- ctx->VSGetConstantBuffers(0, 1, &old.VSConstantBuffer);
|
|
|
|
- ctx->GSGetShader(&old.GS, old.GSInstances, &old.GSInstancesCount);
|
|
|
|
|
|
+ device->PSGetShader(&old.PS, old.PSInstances, &old.PSInstancesCount);
|
|
|
|
+ device->VSGetShader(&old.VS, old.VSInstances, &old.VSInstancesCount);
|
|
|
|
+ device->VSGetConstantBuffers(0, 1, &old.VSConstantBuffer);
|
|
|
|
+ device->GSGetShader(&old.GS, old.GSInstances, &old.GSInstancesCount);
|
|
|
|
|
|
- ctx->IAGetPrimitiveTopology(&old.PrimitiveTopology);
|
|
|
|
- ctx->IAGetIndexBuffer(&old.IndexBuffer, &old.IndexBufferFormat, &old.IndexBufferOffset);
|
|
|
|
- ctx->IAGetVertexBuffers(0, 1, &old.VertexBuffer, &old.VertexBufferStride, &old.VertexBufferOffset);
|
|
|
|
- ctx->IAGetInputLayout(&old.InputLayout);
|
|
|
|
|
|
+ device->IAGetPrimitiveTopology(&old.PrimitiveTopology);
|
|
|
|
+ device->IAGetIndexBuffer(&old.IndexBuffer, &old.IndexBufferFormat, &old.IndexBufferOffset);
|
|
|
|
+ device->IAGetVertexBuffers(0, 1, &old.VertexBuffer, &old.VertexBufferStride, &old.VertexBufferOffset);
|
|
|
|
+ device->IAGetInputLayout(&old.InputLayout);
|
|
|
|
|
|
// Setup desired DX state
|
|
// Setup desired DX state
|
|
- ImGui_ImplDX11_SetupRenderState(draw_data, ctx);
|
|
|
|
|
|
+ ImGui_ImplDX11_SetupRenderState(draw_data, device);
|
|
|
|
+
|
|
|
|
+ // Setup render state structure (for callbacks and custom texture bindings)
|
|
|
|
+ ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
|
|
|
+ ImGui_ImplDX11_RenderState render_state;
|
|
|
|
+ render_state.Device = bd->pd3dDevice;
|
|
|
|
+ render_state.DeviceContext = bd->pd3dDeviceContext;
|
|
|
|
+ render_state.SamplerDefault = bd->pFontSampler;
|
|
|
|
+ platform_io.Renderer_RenderState = &render_state;
|
|
|
|
|
|
// Render command lists
|
|
// Render command lists
|
|
// (Because we merged all buffers into a single one, we maintain our own offset into them)
|
|
// (Because we merged all buffers into a single one, we maintain our own offset into them)
|
|
@@ -259,18 +270,18 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
|
|
ImVec2 clip_off = draw_data->DisplayPos;
|
|
ImVec2 clip_off = draw_data->DisplayPos;
|
|
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
|
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
|
{
|
|
{
|
|
- const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
|
|
|
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
|
|
|
|
|
|
+ const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
|
|
+ for (int cmd_i = 0; cmd_i < draw_list->CmdBuffer.Size; cmd_i++)
|
|
{
|
|
{
|
|
- const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
|
|
|
|
|
|
+ const ImDrawCmd* pcmd = &draw_list->CmdBuffer[cmd_i];
|
|
if (pcmd->UserCallback != nullptr)
|
|
if (pcmd->UserCallback != nullptr)
|
|
{
|
|
{
|
|
// User callback, registered via ImDrawList::AddCallback()
|
|
// 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.)
|
|
// (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.)
|
|
if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
|
|
if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
|
|
- ImGui_ImplDX11_SetupRenderState(draw_data, ctx);
|
|
|
|
|
|
+ ImGui_ImplDX11_SetupRenderState(draw_data, device);
|
|
else
|
|
else
|
|
- pcmd->UserCallback(cmd_list, pcmd);
|
|
|
|
|
|
+ pcmd->UserCallback(draw_list, pcmd);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
@@ -282,36 +293,37 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
|
|
|
|
|
|
// Apply scissor/clipping rectangle
|
|
// Apply scissor/clipping rectangle
|
|
const D3D11_RECT r = { (LONG)clip_min.x, (LONG)clip_min.y, (LONG)clip_max.x, (LONG)clip_max.y };
|
|
const D3D11_RECT r = { (LONG)clip_min.x, (LONG)clip_min.y, (LONG)clip_max.x, (LONG)clip_max.y };
|
|
- ctx->RSSetScissorRects(1, &r);
|
|
|
|
|
|
+ device->RSSetScissorRects(1, &r);
|
|
|
|
|
|
// Bind texture, Draw
|
|
// Bind texture, Draw
|
|
ID3D11ShaderResourceView* texture_srv = (ID3D11ShaderResourceView*)pcmd->GetTexID();
|
|
ID3D11ShaderResourceView* texture_srv = (ID3D11ShaderResourceView*)pcmd->GetTexID();
|
|
- ctx->PSSetShaderResources(0, 1, &texture_srv);
|
|
|
|
- ctx->DrawIndexed(pcmd->ElemCount, pcmd->IdxOffset + global_idx_offset, pcmd->VtxOffset + global_vtx_offset);
|
|
|
|
|
|
+ device->PSSetShaderResources(0, 1, &texture_srv);
|
|
|
|
+ device->DrawIndexed(pcmd->ElemCount, pcmd->IdxOffset + global_idx_offset, pcmd->VtxOffset + global_vtx_offset);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- global_idx_offset += cmd_list->IdxBuffer.Size;
|
|
|
|
- global_vtx_offset += cmd_list->VtxBuffer.Size;
|
|
|
|
|
|
+ global_idx_offset += draw_list->IdxBuffer.Size;
|
|
|
|
+ global_vtx_offset += draw_list->VtxBuffer.Size;
|
|
}
|
|
}
|
|
|
|
+ platform_io.Renderer_RenderState = NULL;
|
|
|
|
|
|
// Restore modified DX state
|
|
// Restore modified DX state
|
|
- ctx->RSSetScissorRects(old.ScissorRectsCount, old.ScissorRects);
|
|
|
|
- ctx->RSSetViewports(old.ViewportsCount, old.Viewports);
|
|
|
|
- ctx->RSSetState(old.RS); if (old.RS) old.RS->Release();
|
|
|
|
- ctx->OMSetBlendState(old.BlendState, old.BlendFactor, old.SampleMask); if (old.BlendState) old.BlendState->Release();
|
|
|
|
- ctx->OMSetDepthStencilState(old.DepthStencilState, old.StencilRef); if (old.DepthStencilState) old.DepthStencilState->Release();
|
|
|
|
- ctx->PSSetShaderResources(0, 1, &old.PSShaderResource); if (old.PSShaderResource) old.PSShaderResource->Release();
|
|
|
|
- ctx->PSSetSamplers(0, 1, &old.PSSampler); if (old.PSSampler) old.PSSampler->Release();
|
|
|
|
- ctx->PSSetShader(old.PS, old.PSInstances, old.PSInstancesCount); if (old.PS) old.PS->Release();
|
|
|
|
|
|
+ device->RSSetScissorRects(old.ScissorRectsCount, old.ScissorRects);
|
|
|
|
+ device->RSSetViewports(old.ViewportsCount, old.Viewports);
|
|
|
|
+ device->RSSetState(old.RS); if (old.RS) old.RS->Release();
|
|
|
|
+ device->OMSetBlendState(old.BlendState, old.BlendFactor, old.SampleMask); if (old.BlendState) old.BlendState->Release();
|
|
|
|
+ device->OMSetDepthStencilState(old.DepthStencilState, old.StencilRef); if (old.DepthStencilState) old.DepthStencilState->Release();
|
|
|
|
+ device->PSSetShaderResources(0, 1, &old.PSShaderResource); if (old.PSShaderResource) old.PSShaderResource->Release();
|
|
|
|
+ device->PSSetSamplers(0, 1, &old.PSSampler); if (old.PSSampler) old.PSSampler->Release();
|
|
|
|
+ device->PSSetShader(old.PS, old.PSInstances, old.PSInstancesCount); if (old.PS) old.PS->Release();
|
|
for (UINT i = 0; i < old.PSInstancesCount; i++) if (old.PSInstances[i]) old.PSInstances[i]->Release();
|
|
for (UINT i = 0; i < old.PSInstancesCount; i++) if (old.PSInstances[i]) old.PSInstances[i]->Release();
|
|
- ctx->VSSetShader(old.VS, old.VSInstances, old.VSInstancesCount); if (old.VS) old.VS->Release();
|
|
|
|
- ctx->VSSetConstantBuffers(0, 1, &old.VSConstantBuffer); if (old.VSConstantBuffer) old.VSConstantBuffer->Release();
|
|
|
|
- ctx->GSSetShader(old.GS, old.GSInstances, old.GSInstancesCount); if (old.GS) old.GS->Release();
|
|
|
|
|
|
+ device->VSSetShader(old.VS, old.VSInstances, old.VSInstancesCount); if (old.VS) old.VS->Release();
|
|
|
|
+ device->VSSetConstantBuffers(0, 1, &old.VSConstantBuffer); if (old.VSConstantBuffer) old.VSConstantBuffer->Release();
|
|
|
|
+ device->GSSetShader(old.GS, old.GSInstances, old.GSInstancesCount); if (old.GS) old.GS->Release();
|
|
for (UINT i = 0; i < old.VSInstancesCount; i++) if (old.VSInstances[i]) old.VSInstances[i]->Release();
|
|
for (UINT i = 0; i < old.VSInstancesCount; i++) if (old.VSInstances[i]) old.VSInstances[i]->Release();
|
|
- ctx->IASetPrimitiveTopology(old.PrimitiveTopology);
|
|
|
|
- ctx->IASetIndexBuffer(old.IndexBuffer, old.IndexBufferFormat, old.IndexBufferOffset); if (old.IndexBuffer) old.IndexBuffer->Release();
|
|
|
|
- ctx->IASetVertexBuffers(0, 1, &old.VertexBuffer, &old.VertexBufferStride, &old.VertexBufferOffset); if (old.VertexBuffer) old.VertexBuffer->Release();
|
|
|
|
- ctx->IASetInputLayout(old.InputLayout); if (old.InputLayout) old.InputLayout->Release();
|
|
|
|
|
|
+ device->IASetPrimitiveTopology(old.PrimitiveTopology);
|
|
|
|
+ device->IASetIndexBuffer(old.IndexBuffer, old.IndexBufferFormat, old.IndexBufferOffset); if (old.IndexBuffer) old.IndexBuffer->Release();
|
|
|
|
+ device->IASetVertexBuffers(0, 1, &old.VertexBuffer, &old.VertexBufferStride, &old.VertexBufferOffset); if (old.VertexBuffer) old.VertexBuffer->Release();
|
|
|
|
+ device->IASetInputLayout(old.InputLayout); if (old.InputLayout) old.InputLayout->Release();
|
|
}
|
|
}
|
|
|
|
|
|
static void ImGui_ImplDX11_CreateFontsTexture()
|
|
static void ImGui_ImplDX11_CreateFontsTexture()
|
|
@@ -365,9 +377,9 @@ static void ImGui_ImplDX11_CreateFontsTexture()
|
|
D3D11_SAMPLER_DESC desc;
|
|
D3D11_SAMPLER_DESC desc;
|
|
ZeroMemory(&desc, sizeof(desc));
|
|
ZeroMemory(&desc, sizeof(desc));
|
|
desc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
|
|
desc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
|
|
- desc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
|
|
|
|
- desc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
|
|
|
|
- desc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
|
|
|
|
|
|
+ desc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
|
|
|
|
+ desc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
|
|
|
|
+ desc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
|
|
desc.MipLODBias = 0.f;
|
|
desc.MipLODBias = 0.f;
|
|
desc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
|
|
desc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
|
|
desc.MinLOD = 0.f;
|
|
desc.MinLOD = 0.f;
|