Browse Source

Upload whole point buffer, and align its size to 8K

ssao
A.Olokhtonov 1 year ago
parent
commit
e3ae4cf6cd
  1. 1
      client/client_send.js
  2. 24
      client/index.html
  3. 6
      client/webgl_draw.js
  4. 11
      client/webgl_geometry.js

1
client/client_send.js

@ -41,6 +41,7 @@ function ser_u32(s, value) { @@ -41,6 +41,7 @@ function ser_u32(s, value) {
}
function ser_align(s, to) {
// TODO: non-stupid version of this
while (s.offset % to != 0) {
s.offset++;
}

24
client/index.html

@ -7,20 +7,20 @@ @@ -7,20 +7,20 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="shortcut icon" href="icons/favicon.svg" id="favicon">
<link rel="stylesheet" type="text/css" href="default.css?v=38">
<link rel="stylesheet" type="text/css" href="default.css?v=40">
<script type="text/javascript" src="aux.js?v=38"></script>
<script type="text/javascript" src="math.js?v=38"></script>
<script type="text/javascript" src="tools.js?v=38"></script>
<script type="text/javascript" src="webgl_geometry.js?v=38"></script>
<script type="text/javascript" src="webgl_shaders.js?v=38"></script>
<script type="text/javascript" src="webgl_listeners.js?v=38"></script>
<script type="text/javascript" src="webgl_draw.js?v=38"></script>
<script type="text/javascript" src="index.js?v=38"></script>
<script type="text/javascript" src="aux.js?v=40"></script>
<script type="text/javascript" src="math.js?v=40"></script>
<script type="text/javascript" src="tools.js?v=40"></script>
<script type="text/javascript" src="webgl_geometry.js?v=40"></script>
<script type="text/javascript" src="webgl_shaders.js?v=40"></script>
<script type="text/javascript" src="webgl_listeners.js?v=40"></script>
<script type="text/javascript" src="webgl_draw.js?v=40"></script>
<script type="text/javascript" src="index.js?v=40"></script>
<script type="text/javascript" src="client_send.js?v=38"></script>
<script type="text/javascript" src="client_recv.js?v=38"></script>
<script type="text/javascript" src="websocket.js?v=38"></script>
<script type="text/javascript" src="client_send.js?v=40"></script>
<script type="text/javascript" src="client_recv.js?v=40"></script>
<script type="text/javascript" src="websocket.js?v=40"></script>
</head>
<body>
<div class="main">

6
client/webgl_draw.js

@ -42,12 +42,12 @@ function draw(state, context) { @@ -42,12 +42,12 @@ function draw(state, context) {
const npoints = context.point_serializer.offset / (4 * 2);
const nstrokes = context.quad_serializer.offset / (6 * 4 * 4);
ser_align(context.point_serializer, 8192);
if (npoints > 0) {
// TOOD: if points changed
if (true) {
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RG32F, Math.min(npoints, 8192), Math.max(1, Math.ceil(npoints / 8192)), 0, gl.RG, gl.FLOAT, new Float32Array(context.point_serializer.buffer, 0, context.point_serializer.offset / 4));
const texture_width = Math.min(npoints, 8192);
const texture_height = Math.max(1, Math.ceil(npoints / 8192));
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RG32F, texture_width, texture_height, 0, gl.RG, gl.FLOAT, new Float32Array(context.point_serializer.buffer, 0, context.point_serializer.size / 4));
}
gl.activeTexture(gl.TEXTURE0 + 1);

11
client/webgl_geometry.js

@ -39,7 +39,7 @@ function push_stroke(context, stroke) { @@ -39,7 +39,7 @@ function push_stroke(context, stroke) {
// if (stroke.stroke_id !== 1123776468) {
// return;
// }
const stroke_width = stroke.width;
const points = stroke.points;
const color_u32 = stroke.color;
@ -132,14 +132,17 @@ function geometry_prepare_stroke(state) { @@ -132,14 +132,17 @@ function geometry_prepare_stroke(state) {
function geometry_add_stroke(state, context, stroke) {
if (!state.online || !stroke) return;
if (stroke.points.length < 2) return;
const stroke_quads = count_stroke_quads(stroke.points);
// const stroke_quads = Math.ceil(stroke.points.length / MAX_POINTS_PER_QUAD);
// Points
const point_bytes_left = context.point_serializer.size - context.point_serializer.offset;
const point_bytes_needed = stroke.points.length * config.bytes_per_point;
let point_bytes_left = context.point_serializer.size - context.point_serializer.offset;
let point_bytes_needed = stroke.points.length * config.bytes_per_point;
if (point_bytes_needed % 8192 != 0) {
point_bytes_needed += 8192 - point_bytes_needed % 8192;
}
if (point_bytes_left < point_bytes_needed) {
const extend_points_by = Math.ceil((context.point_serializer.size + point_bytes_needed) * 1.62);

Loading…
Cancel
Save