From 2a94d4625cb859913edd3f0651732f130b755669 Mon Sep 17 00:00:00 2001 From: "A.Olokhtonov" Date: Tue, 26 Nov 2024 00:38:53 +0300 Subject: [PATCH] Temprorarily undo busted partial texture uploads --- client/webgl_draw.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/client/webgl_draw.js b/client/webgl_draw.js index 143469a..f99cc85 100644 --- a/client/webgl_draw.js +++ b/client/webgl_draw.js @@ -23,7 +23,29 @@ function upload_if_needed(gl, buffer_kind, serializer) { serializer.gpu_upload_from = serializer.offset; } } +function upload_square_rgba16ui_texture(gl, serializer, texture_size) { + // TODO: only subupload what's needed + const bpp = 2 * 4; + const data_size = serializer.offset; + const data_pixels = data_size / bpp; // data_size % bpp is expected to always be zero here + const rows = Math.ceil(data_pixels / texture_size); + const last_row = data_pixels % texture_size; + const whole_upload = (rows - 1) * texture_size * bpp; + + // Upload whole rows + if (rows > 1) { + gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, texture_size, rows - 1, gl.RGBA_INTEGER, gl.UNSIGNED_SHORT, new Uint16Array(serializer.buffer, 0, whole_upload / 2)); + } + + // Upload last row + if (last_row > 0) { + const last_row_upload = last_row * bpp; + gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, rows - 1, last_row, 1, gl.RGBA_INTEGER, gl.UNSIGNED_SHORT, new Uint16Array(serializer.buffer, whole_upload, last_row_upload / 2)); + } +} +/* + PLS FIX ME function upload_square_rgba16ui_texture(gl, serializer, texture_size) { const bpp = 2 * 4; const data_size = serializer.offset - serializer.gpu_upload_from; @@ -66,6 +88,7 @@ function upload_square_rgba16ui_texture(gl, serializer, texture_size) { serializer.gpu_upload_from = serializer.offset; } +*/ function draw_html(state) { // HUD-like things. Player cursors, screens