Permalink
Browse files

Port a small simplification to D3D9

  • Loading branch information...
hrydgard committed Jun 9, 2017
1 parent 5f6e0fe commit dfdf54813a17891f2f612a7d8295171c82141520
Showing with 7 additions and 15 deletions.
  1. +2 −2 GPU/D3D11/StencilBufferD3D11.cpp
  2. +5 −13 GPU/Directx9/StencilBufferDX9.cpp
@@ -202,8 +202,8 @@ bool FramebufferManagerD3D11::NotifyStencilUpload(u32 addr, int size, bool skipZ
context_->RSSetViewports(1, &vp);
float coord[20] = {
-1.0f, 1.0f, 0.0f, 0.0f, 0.0f,
1.0f, 1.0f, 0.0f, u1, 0.0f,
-1.0f, 1.0f, 0.0f, 0.0f, 0.0f,
1.0f, 1.0f, 0.0f, u1, 0.0f,
-1.0f, -1.0f, 0.0f, 0.0f, v1,
1.0f, -1.0f, 0.0f, u1, v1,
};
@@ -234,20 +234,12 @@ bool FramebufferManagerDX9::NotifyStencilUpload(u32 addr, int size, bool skipZer
dxstate.stencilFunc.set(D3DCMP_ALWAYS, 0xFF, 0xFF);
float fw = dstBuffer->width;
float fh = dstBuffer->height;
float coord[20] = {
0.0f,0.0f,0.0f, 0.0f,0.0f,
fw,0.0f,0.0f, u1,0.0f,
fw,fh,0.0f, u1,v1,
0.0f,fh,0.0f, 0.0f,v1,
-1.0f, 1.0f, 0.0f, 0.0f, 0.0f,
1.0f, 1.0f, 0.0f, u1, 0.0f,
-1.0f, -1.0f, 0.0f, 0.0f, v1,
1.0f, -1.0f, 0.0f, u1, v1,
};
float invDestW = 1.0f / (fw * 0.5f);
float invDestH = 1.0f / (fh * 0.5f);
for (int i = 0; i < 4; i++) {
coord[i * 5] = coord[i * 5] * invDestW - 1.0f;
coord[i * 5 + 1] = -(coord[i * 5 + 1] * invDestH - 1.0f);
}
device_->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
@@ -278,7 +270,7 @@ bool FramebufferManagerDX9::NotifyStencilUpload(u32 addr, int size, bool skipZer
const float f[4] = {i * (1.0f / 255.0f)};
device_->SetPixelShaderConstantF(CONST_PS_STENCILVALUE, f, 1);
}
HRESULT hr = device_->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, coord, 5 * sizeof(float));
HRESULT hr = device_->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, coord, 5 * sizeof(float));
if (FAILED(hr)) {
ERROR_LOG_REPORT(G3D, "Failed to draw stencil bit %x: %08x", i, hr);
}

0 comments on commit dfdf548

Please sign in to comment.