Gpu cleanup
This commit is contained in:
@@ -4,10 +4,10 @@ let line_draw_strength: f32 = 0.005;
|
||||
let line_draw_mat: mat4_t = mat4_nan();
|
||||
let line_draw_dim: vec4_t = vec4_nan();
|
||||
|
||||
let line_draw_vertex_buffer: iron_gpu_buffer_t;
|
||||
let line_draw_index_buffer: iron_gpu_buffer_t;
|
||||
let line_draw_pipeline: iron_gpu_pipeline_t = null;
|
||||
let line_draw_overlay_pipeline: iron_gpu_pipeline_t = null;
|
||||
let line_draw_vertex_buffer: gpu_buffer_t;
|
||||
let line_draw_index_buffer: gpu_buffer_t;
|
||||
let line_draw_pipeline: gpu_pipeline_t = null;
|
||||
let line_draw_overlay_pipeline: gpu_pipeline_t = null;
|
||||
|
||||
let line_draw_vp: mat4_t;
|
||||
let line_draw_vp_loc: i32;
|
||||
@@ -40,7 +40,7 @@ let line_draw_camera_look: vec4_t = vec4_create();
|
||||
|
||||
function line_draw_init() {
|
||||
if (line_draw_pipeline == null) {
|
||||
let structure: iron_gpu_vertex_structure_t = gpu_vertex_struct_create();
|
||||
let structure: gpu_vertex_structure_t = gpu_vertex_struct_create();
|
||||
gpu_vertex_struct_add(structure, "pos", vertex_data_t.F32_3X);
|
||||
line_draw_pipeline = gpu_create_pipeline();
|
||||
line_draw_pipeline.input_layout = structure;
|
||||
@@ -63,7 +63,7 @@ function line_draw_init() {
|
||||
line_draw_index_buffer = gpu_create_index_buffer(line_draw_max_indices);
|
||||
}
|
||||
if (line_draw_overlay_pipeline == null) {
|
||||
let structure: iron_gpu_vertex_structure_t = gpu_vertex_struct_create();
|
||||
let structure: gpu_vertex_structure_t = gpu_vertex_struct_create();
|
||||
gpu_vertex_struct_add(structure, "pos", vertex_data_t.F32_3X);
|
||||
line_draw_overlay_pipeline = gpu_create_pipeline();
|
||||
line_draw_overlay_pipeline.input_layout = structure;
|
||||
@@ -228,12 +228,12 @@ function line_draw_begin() {
|
||||
}
|
||||
|
||||
function line_draw_end(overlay: bool = false) {
|
||||
iron_gpu_vertex_buffer_unlock(line_draw_vertex_buffer);
|
||||
iron_gpu_index_buffer_unlock(line_draw_index_buffer);
|
||||
gpu_vertex_buffer_unlock(line_draw_vertex_buffer);
|
||||
gpu_index_buffer_unlock(line_draw_index_buffer);
|
||||
|
||||
iron_gpu_set_vertex_buffer(line_draw_vertex_buffer);
|
||||
iron_gpu_set_index_buffer(line_draw_index_buffer);
|
||||
iron_gpu_set_pipeline(overlay ? line_draw_overlay_pipeline : line_draw_pipeline);
|
||||
gpu_set_vertex_buffer(line_draw_vertex_buffer);
|
||||
gpu_set_index_buffer(line_draw_index_buffer);
|
||||
gpu_set_pipeline(overlay ? line_draw_overlay_pipeline : line_draw_pipeline);
|
||||
let camera: camera_object_t = scene_camera;
|
||||
line_draw_vp = mat4_clone(camera.v);
|
||||
line_draw_vp = mat4_mult_mat(line_draw_vp, camera.p);
|
||||
@@ -248,8 +248,8 @@ function line_draw_end(overlay: bool = false) {
|
||||
////
|
||||
}
|
||||
|
||||
let _shape_draw_sphere_vb: iron_gpu_buffer_t = null;
|
||||
let _shape_draw_sphere_ib: iron_gpu_buffer_t = null;
|
||||
let _shape_draw_sphere_vb: gpu_buffer_t = null;
|
||||
let _shape_draw_sphere_ib: gpu_buffer_t = null;
|
||||
|
||||
function shape_draw_sphere(mat: mat4_t) {
|
||||
line_draw_init();
|
||||
@@ -259,7 +259,7 @@ function shape_draw_sphere(mat: mat4_t) {
|
||||
let md: mesh_data_t = sphere.data;
|
||||
|
||||
let posa: i16_array_t = md.vertex_arrays[0].values;
|
||||
let structure: iron_gpu_vertex_structure_t = gpu_vertex_struct_create();
|
||||
let structure: gpu_vertex_structure_t = gpu_vertex_struct_create();
|
||||
gpu_vertex_struct_add(structure, "pos", vertex_data_t.F32_3X);
|
||||
_shape_draw_sphere_vb = gpu_create_vertex_buffer(posa.length, structure, usage_t.STATIC);
|
||||
let data: buffer_t = gpu_lock_vertex_buffer(_shape_draw_sphere_vb);
|
||||
@@ -268,13 +268,13 @@ function shape_draw_sphere(mat: mat4_t) {
|
||||
buffer_set_f32(data, (i * 3 + 1) * 4, posa[i * 4 + 1] / 32767);
|
||||
buffer_set_f32(data, (i * 3 + 2) * 4, posa[i * 4 + 2] / 32767);
|
||||
}
|
||||
iron_gpu_vertex_buffer_unlock(_shape_draw_sphere_vb);
|
||||
gpu_vertex_buffer_unlock(_shape_draw_sphere_vb);
|
||||
_shape_draw_sphere_ib = md._.index_buffers[0];
|
||||
}
|
||||
|
||||
iron_gpu_set_vertex_buffer(_shape_draw_sphere_vb);
|
||||
iron_gpu_set_index_buffer(_shape_draw_sphere_ib);
|
||||
iron_gpu_set_pipeline(line_draw_overlay_pipeline);
|
||||
gpu_set_vertex_buffer(_shape_draw_sphere_vb);
|
||||
gpu_set_index_buffer(_shape_draw_sphere_ib);
|
||||
gpu_set_pipeline(line_draw_overlay_pipeline);
|
||||
let camera: camera_object_t = scene_camera;
|
||||
line_draw_vp = mat4_clone(mat);
|
||||
let f: f32 = line_draw_strength * 50;
|
||||
|
||||
Reference in New Issue
Block a user