Skip to content

Commit 8fce1e7

Browse files
committed
implement variable sized bg in dx10
1 parent 4483cb3 commit 8fce1e7

File tree

3 files changed

+28
-26
lines changed

3 files changed

+28
-26
lines changed

IntelPresentMon/FlashInjectorLibrary/Extension/OverlayRenderer.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ namespace GfxLayer::Extension
4949
static T MakeViewport(const RECT& r)
5050
{
5151
return T{
52-
.TopLeftX = FLOAT(r.left),
53-
.TopLeftY = FLOAT(r.top),
54-
.Width = FLOAT(r.right - r.left),
55-
.Height = FLOAT(r.bottom - r.top),
52+
.TopLeftX = decltype(std::declval<T>().TopLeftX)(r.left),
53+
.TopLeftY = decltype(std::declval<T>().TopLeftY)(r.top),
54+
.Width = decltype(std::declval<T>().Width)(r.right - r.left),
55+
.Height = decltype(std::declval<T>().Height)(r.bottom - r.top),
5656
};
5757
}
5858

IntelPresentMon/FlashInjectorLibrary/Extension/OverlayRenderer_D3D10.cpp

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -124,19 +124,6 @@ namespace GfxLayer::Extension
124124

125125
void OverlayRenderer_D3D10::Render(bool renderBar, bool useRainbow, bool enableBackground)
126126
{
127-
ID3D10Buffer* pConstantBuffer = nullptr;
128-
if (renderBar) {
129-
if (useRainbow) {
130-
pConstantBuffer = m_rainbowConstantBufferPtrs[GetRainbowIndex()].Get();
131-
}
132-
else {
133-
pConstantBuffer = m_pConstantBufferBar.Get();
134-
}
135-
}
136-
else {
137-
pConstantBuffer = m_pConstantBufferBackground.Get();
138-
}
139-
140127
// Capture the current state
141128

142129
m_pStateBlock->Capture();
@@ -160,17 +147,33 @@ namespace GfxLayer::Extension
160147
UINT stride = sizeof(Quad::Vertex);
161148
UINT offset = 0;
162149

150+
// set common state
163151
m_pDevice->ClearState();
164-
m_pDevice->RSSetViewports(1, &m_Viewport);
165152
m_pDevice->OMSetRenderTargets(1, &pRtv, nullptr);
166153
m_pDevice->IASetInputLayout(m_pVertexLayout.Get());
167154
m_pDevice->IASetVertexBuffers(0, 1, &pVertexBuffer, &stride, &offset);
168155
m_pDevice->IASetIndexBuffer(m_pIndexBuffer.Get(), DXGI_FORMAT_R32_UINT, 0);
169156
m_pDevice->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
170157
m_pDevice->VSSetShader(m_pVertexShader.Get());
171-
m_pDevice->PSSetConstantBuffers(0, 1, &pConstantBuffer);
172158
m_pDevice->PSSetShader(m_pPixelShader.Get());
173-
m_pDevice->DrawIndexed(6, 0, 0);
159+
// issue fg/bg draw calls
160+
const auto Draw = [&](ID3D10Buffer* pConstantBuffer, const D3D10_VIEWPORT& vp) {
161+
m_pDevice->RSSetViewports(1, &vp);
162+
m_pDevice->PSSetConstantBuffers(0, 1, &pConstantBuffer);
163+
m_pDevice->DrawIndexed(6, 0, 0);
164+
};
165+
if (renderBar) {
166+
if (enableBackground && m_backgroundViewport.Width > m_foregrountViewport.Width) {
167+
Draw(m_pConstantBufferBackground.Get(), m_backgroundViewport);
168+
}
169+
Draw(useRainbow ?
170+
m_rainbowConstantBufferPtrs[GetRainbowIndex()].Get() :
171+
m_pConstantBufferBar.Get(),
172+
m_foregrountViewport);
173+
}
174+
else {
175+
Draw(m_pConstantBufferBackground.Get(), m_backgroundViewport);
176+
}
174177

175178
// Restore the previous state
176179

@@ -179,11 +182,9 @@ namespace GfxLayer::Extension
179182

180183
void OverlayRenderer_D3D10::UpdateViewport(const OverlayConfig& cfg)
181184
{
182-
auto rect = GetScissorRects().fg;
183-
m_Viewport.TopLeftX = rect.left;
184-
m_Viewport.TopLeftY = rect.top;
185-
m_Viewport.Width = rect.right - rect.left;
186-
m_Viewport.Height = rect.bottom - rect.top;
185+
const auto scissors = GetScissorRects();
186+
m_foregrountViewport = MakeViewport<D3D10_VIEWPORT>(scissors.fg);
187+
m_backgroundViewport = MakeViewport<D3D10_VIEWPORT>(scissors.bg);
187188
}
188189

189190
void OverlayRenderer_D3D10::UpdateConfig(const OverlayConfig& cfg)

IntelPresentMon/FlashInjectorLibrary/Extension/OverlayRenderer_D3D10.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ namespace GfxLayer::Extension
5353
ComPtr<ID3D10InputLayout> m_pVertexLayout;
5454
ComPtr<ID3D10StateBlock> m_pStateBlock;
5555

56-
D3D10_VIEWPORT m_Viewport{};
56+
D3D10_VIEWPORT m_foregrountViewport{};
57+
D3D10_VIEWPORT m_backgroundViewport{};
5758
};
5859
}

0 commit comments

Comments
 (0)