Skip to content

PS2 games in the browser: static recompilation to WebAssembly with a native runtime

C++

GPU: upscaled sprites cover whole native pixels

Samir Nuri2ac268e1373d
diff --git a/runtime/src/gs/gpu/gpu.cpp b/runtime/src/gs/gpu/gpu.cpp
index 5013156..06a522b 100644
--- a/runtime/src/gs/gpu/gpu.cpp
+++ b/runtime/src/gs/gpu/gpu.cpp
@@ -1038,9 +1038,9 @@ void draw(const State &st, const Vertex *v, int count) {
}
case 6: {
const float x0 = sx(v[0]), y0 = sy(v[0]), x1 = sx(v[1]), y1 = sy(v[1]);
- minx = std::max(scax0, first(std::min(x0, x1)));
+ minx = std::max(scax0, static_cast<int>(std::ceil(std::min(x0, x1))));
maxx = std::min(scax1, static_cast<int>(std::ceil(std::max(x0, x1))) - 1);
- miny = std::max(scay0, first(std::min(y0, y1)));
+ miny = std::max(scay0, static_cast<int>(std::ceil(std::min(y0, y1))));
maxy = std::min(scay1, static_cast<int>(std::ceil(std::max(y0, y1))) - 1);
rec[1] = 1;
rec[4] = f2u(x0);
diff --git a/runtime/src/gs/gpu/gs.wgsl b/runtime/src/gs/gpu/gs.wgsl
index 9077a36..9ef4e32 100644
--- a/runtime/src/gs/gpu/gs.wgsl
+++ b/runtime/src/gs/gpu/gs.wgsl
@@ -996,7 +996,9 @@ fn shade_at(p: u32, s: Setup, x: i32, y: i32, k: u32, px: f32, py: f32) {
if (point && abs(dv) >= abs(dy) * 0.999) {
uy = f32(y);
}
- if (SCALE > 1u && (ux < min(x0, x0 + dx) || ux >= max(x0, x0 + dx) || uy < min(y0, y0 + dy) || uy >= max(y0, y0 + dy))) {
+ let cx = f32(x);
+ let cy = f32(y);
+ if (SCALE > 1u && (cx < min(x0, x0 + dx) || cx >= max(x0, x0 + dx) || cy < min(y0, y0 + dy) || cy >= max(y0, y0 + dy))) {
return;
}
var tx = 0.0;