37 lines
1.8 KiB
C++
37 lines
1.8 KiB
C++
#include "../../src/host/blend_state.h"
|
|
#include "../../src/host/draw_capture.h"
|
|
#include <cstdio>
|
|
|
|
int main(int argc, char** argv) {
|
|
int failures = 0;
|
|
auto check = [&](bool ok, const char* message) {
|
|
if (!ok) { std::fprintf(stderr, "FAIL %s\n", message); ++failures; }
|
|
};
|
|
using mt_host::d3d_blend_for_rgb_target;
|
|
check(d3d_blend_for_rgb_target(7) == 2, "gungsin DESTALPHA preserves the background on XRGB");
|
|
check(d3d_blend_for_rgb_target(8) == 1, "INVDESTALPHA contributes zero on XRGB");
|
|
check(d3d_blend_for_rgb_target(11) == 1, "SRCALPHASAT contributes zero RGB on XRGB");
|
|
for (std::uint8_t factor = 1; factor <= 10; ++factor)
|
|
if (factor != 7 && factor != 8)
|
|
check(d3d_blend_for_rgb_target(factor) == factor, "ordinary alpha/additive/color factors preserved");
|
|
if (argc == 2) {
|
|
std::vector<Render3DDraw> draws;
|
|
// An opaque scene draw can output alpha 0 into Vulkan's RGBA storage.
|
|
// Gungsin's SRCALPHA / DESTALPHA must still preserve that XRGB background.
|
|
for (auto color : {0x00804020u, 0x800080ffu}) {
|
|
Render3DDraw d{};
|
|
for (auto* matrix : {d.world, d.view, d.proj})
|
|
for (int i = 0; i < 16; ++i) matrix[i] = (i % 5 == 0) ? 1 : 0;
|
|
d.positions = {-1,-1,0.5f, 1,-1,0.5f, 1,1,0.5f, -1,1,0.5f};
|
|
d.indices = {0,1,2,0,2,3};
|
|
d.diffuse = {color,color,color,color};
|
|
d.color_op[0] = d.alpha_op[0] = 2; // SELECTARG1 / DIFFUSE
|
|
d.color_op[1] = d.alpha_op[1] = 1; // DISABLE
|
|
if (!draws.empty()) { d.alpha_blend = 1; d.src_blend = 5; d.dest_blend = 7; }
|
|
draws.push_back(std::move(d));
|
|
}
|
|
native_draw_capture::write(argv[1], draws, {}, 960, 640, {});
|
|
}
|
|
return failures ? 1 : 0;
|
|
}
|