Skip to content

Commit fd97d82

Browse files
D3D9: Correct shader bounds apply.
Also, use triangle strip like D3D11.
1 parent d9510f8 commit fd97d82

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

GPU/Directx9/TextureCacheDX9.cpp

+14-14
Original file line numberDiff line numberDiff line change
@@ -320,14 +320,14 @@ class TextureShaderApplierDX9 {
320320
static const Pos pos[4] = {
321321
{-1, 1, 0},
322322
{ 1, 1, 0},
323-
{ 1, -1, 0},
324323
{-1, -1, 0},
324+
{ 1, -1, 0},
325325
};
326326
static const UV uv[4] = {
327327
{0, 0},
328328
{1, 0},
329-
{1, 1},
330329
{0, 1},
330+
{1, 1},
331331
};
332332

333333
for (int i = 0; i < 4; ++i) {
@@ -354,25 +354,25 @@ class TextureShaderApplierDX9 {
354354

355355
const float left = u1 * invHalfWidth - 1.0f + xoff;
356356
const float right = u2 * invHalfWidth - 1.0f + xoff;
357-
const float top = v1 * invHalfHeight - 1.0f + yoff;
358-
const float bottom = v2 * invHalfHeight - 1.0f + yoff;
357+
const float top = (bufferH_ - v1) * invHalfHeight - 1.0f + yoff;
358+
const float bottom = (bufferH_ - v2) * invHalfHeight - 1.0f + yoff;
359359

360360
float z = 0.0f;
361-
// Points are: BL, BR, TR, TL.
362-
verts_[0].pos = Pos(left, bottom, z);
363-
verts_[1].pos = Pos(right, bottom, z);
364-
verts_[2].pos = Pos(right, top, z);
365-
verts_[3].pos = Pos(left, top, z);
361+
verts_[0].pos = Pos(left, top, z);
362+
verts_[1].pos = Pos(right, top, z);
363+
verts_[2].pos = Pos(left, bottom, z);
364+
verts_[3].pos = Pos(right, bottom, z);
366365

367366
// And also the UVs, same order.
368367
const float uvleft = u1 * invWidth;
369368
const float uvright = u2 * invWidth;
370369
const float uvtop = v1 * invHeight;
371370
const float uvbottom = v2 * invHeight;
372-
verts_[0].uv = UV(uvleft, uvbottom);
373-
verts_[1].uv = UV(uvright, uvbottom);
374-
verts_[2].uv = UV(uvright, uvtop);
375-
verts_[3].uv = UV(uvleft, uvtop);
371+
372+
verts_[0].uv = UV(uvleft, uvtop);
373+
verts_[1].uv = UV(uvright, uvtop);
374+
verts_[2].uv = UV(uvleft, uvbottom);
375+
verts_[3].uv = UV(uvright, uvbottom);
376376

377377
// We need to reapply the texture next time since we cropped UV.
378378
gstate_c.Dirty(DIRTY_TEXTURE_PARAMS);
@@ -396,7 +396,7 @@ class TextureShaderApplierDX9 {
396396

397397
D3DVIEWPORT9 vp{ 0, 0, (DWORD)renderW_, (DWORD)renderH_, 0.0f, 1.0f };
398398
device_->SetViewport(&vp);
399-
HRESULT hr = device_->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, verts_, (3 + 2) * sizeof(float));
399+
HRESULT hr = device_->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, verts_, (3 + 2) * sizeof(float));
400400
if (FAILED(hr)) {
401401
ERROR_LOG_REPORT(G3D, "Depal render failed: %08x", hr);
402402
}

0 commit comments

Comments
 (0)