Owner-authorized source migration: 31 helper-only translation units were merged into their callers or existing inline headers; both build manifests updated. Includes the preserved source payload, Lua configuration matching wowdecomp, and exact malloca expansion without diagnostic pragmas. 449 native units compiled locally and 449 staged units compiled by the pinned server toolchain. No previously byte-matched function regressed. Compiler mapping diagnostics remain recorded as needs_cleanup, not accepted or peer-confirmed. Existing independent review records are preserved. README.md is intentionally unchanged.
78 lines
2.9 KiB
C++
78 lines
2.9 KiB
C++
#include "Render/DX9/DeviceStateDX9.h"
|
|
#include "Render/Primitives/RenderQueues.h"
|
|
#include "Render/DX9/RendererDX9Operations.h"
|
|
#include "Render/DX9/TextureDX9.h"
|
|
|
|
#include <algorithm>
|
|
#include <cstdint>
|
|
|
|
namespace {
|
|
// INLINED
|
|
bool Before(const DepthPrimitive& left, const DepthPrimitive& right) {
|
|
if (left.depth < right.depth) {
|
|
return true;
|
|
}
|
|
|
|
if (right.depth < left.depth) {
|
|
return false;
|
|
}
|
|
|
|
return left.depth == right.depth && reinterpret_cast<std::uintptr_t>(left.primitive) < reinterpret_cast<std::uintptr_t>(right.primitive);
|
|
}
|
|
|
|
// INLINED
|
|
bool WritesDepth(const RenderCommand& command) {
|
|
return (command.unknown_0014 & 0xFFu) != 0 && (command.unknown_0014 & 0xFF00u) != 0;
|
|
}
|
|
}
|
|
|
|
// OFFSET: 0x00565DA0
|
|
// FUNCTION: fn_02224
|
|
void RendererDX9Operations::DrawAlphaQueues(RenderQueues& queues, unsigned char twoPass) {
|
|
ScopedDeviceStateDX9 restore(this->state);
|
|
std::sort(queues.queue_018C.begin(), queues.queue_018C.end(), Before);
|
|
std::sort(queues.queue_01BC.begin(), queues.queue_01BC.end(), Before);
|
|
this->state.SetRenderState(D3DRS_ALPHABLENDENABLE, 1);
|
|
this->state.SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
|
this->state.SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
|
|
this->state.SetRenderState(D3DRS_ALPHATESTENABLE, 1);
|
|
this->state.SetRenderState(D3DRS_ALPHAREF, 1);
|
|
this->state.SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL);
|
|
|
|
const auto draw = [&](const std::vector<DepthPrimitive>& queue, bool alphaTest) {
|
|
for (const DepthPrimitive& entry : queue) {
|
|
RenderCommand& command = *entry.primitive;
|
|
|
|
if (alphaTest) {
|
|
this->state.SetRenderState(D3DRS_ALPHAREF, WritesDepth(command) ? 1 : 240);
|
|
} else {
|
|
this->state.SetRenderState(D3DRS_ZWRITEENABLE, WritesDepth(command));
|
|
}
|
|
|
|
this->state.SetTexture(0, command.texture ? static_cast<CTextureDX9*>(command.texture)->NativeTexture() : nullptr);
|
|
this->DrawPrimitive(&command);
|
|
}
|
|
};
|
|
const auto drawPair = [&](bool alphaTest) {
|
|
this->state.SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
|
|
this->state.SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
|
|
draw(queues.queue_018C, alphaTest);
|
|
this->state.SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
|
|
this->state.SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);
|
|
draw(queues.queue_01BC, alphaTest);
|
|
};
|
|
|
|
if (twoPass == 1) {
|
|
this->state.SetRenderState(D3DRS_ZWRITEENABLE, 1);
|
|
this->state.SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL);
|
|
drawPair(true);
|
|
this->state.SetRenderState(D3DRS_ZWRITEENABLE, 0);
|
|
this->state.SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_LESS);
|
|
drawPair(true);
|
|
this->state.SetRenderState(D3DRS_ALPHAREF, 1);
|
|
this->state.SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL);
|
|
this->DrawDepthQueue(queues.queue_01A4, true);
|
|
} else {
|
|
drawPair(false);
|
|
}
|
|
}
|