paint: update draw shaders

This commit is contained in:
luboslenco
2026-04-29 07:31:24 +02:00
parent 881fe57a3a
commit 0c7516d4ad
9 changed files with 66 additions and 80 deletions
+5 -12
View File
@@ -1,9 +1,7 @@
#[set(everything)] #[set(everything)]
const constants: { const constants: {
pos: float4; // xywh empty: float4;
tex: float4; // xywh
col: float4;
}; };
#[set(everything)] #[set(everything)]
@@ -14,6 +12,8 @@ const tex: tex2d;
struct vert_in { struct vert_in {
pos: float2; pos: float2;
tex: float2;
col: float4;
} }
struct vert_out { struct vert_out {
@@ -24,16 +24,9 @@ struct vert_out {
fun layer_copy_vert(input: vert_in): vert_out { fun layer_copy_vert(input: vert_in): vert_out {
var output: vert_out; var output: vert_out;
var cpos: float4 = constants.pos;
var ctex: float4 = constants.tex;
output.pos = float4(input.pos, 0.0, 1.0); output.pos = float4(input.pos, 0.0, 1.0);
output.pos.xy = output.pos.xy * cpos.zw + cpos.xy; output.tex = input.tex;
output.pos.xy = output.pos.xy * 2.0 - 1.0; output.col = input.col;
output.pos.y = -output.pos.y;
output.tex = input.pos * ctex.zw + ctex.xy;
output.col = constants.col;
return output; return output;
} }
+5 -12
View File
@@ -1,9 +1,7 @@
#[set(everything)] #[set(everything)]
const constants: { const constants: {
pos: float4; // xywh empty: float4;
tex: float4; // xywh
col: float4;
}; };
#[set(everything)] #[set(everything)]
@@ -14,6 +12,8 @@ const tex: tex2d;
struct vert_in { struct vert_in {
pos: float2; pos: float2;
tex: float2;
col: float4;
} }
struct vert_out { struct vert_out {
@@ -24,16 +24,9 @@ struct vert_out {
fun layer_copy_bgra_vert(input: vert_in): vert_out { fun layer_copy_bgra_vert(input: vert_in): vert_out {
var output: vert_out; var output: vert_out;
var cpos: float4 = constants.pos;
var ctex: float4 = constants.tex;
output.pos = float4(input.pos, 0.0, 1.0); output.pos = float4(input.pos, 0.0, 1.0);
output.pos.xy = output.pos.xy * cpos.zw + cpos.xy; output.tex = input.tex;
output.pos.xy = output.pos.xy * 2.0 - 1.0; output.col = input.col;
output.pos.y = -output.pos.y;
output.tex = input.pos * ctex.zw + ctex.xy;
output.col = constants.col;
return output; return output;
} }
+5 -12
View File
@@ -1,9 +1,7 @@
#[set(everything)] #[set(everything)]
const constants: { const constants: {
pos: float4; // xywh empty: float4;
tex: float4; // xywh
col: float4;
}; };
#[set(everything)] #[set(everything)]
@@ -14,6 +12,8 @@ const tex: tex2d;
struct vert_in { struct vert_in {
pos: float2; pos: float2;
tex: float2;
col: float4;
} }
struct vert_out { struct vert_out {
@@ -24,16 +24,9 @@ struct vert_out {
fun layer_invert_vert(input: vert_in): vert_out { fun layer_invert_vert(input: vert_in): vert_out {
var output: vert_out; var output: vert_out;
var cpos: float4 = constants.pos;
var ctex: float4 = constants.tex;
output.pos = float4(input.pos, 0.0, 1.0); output.pos = float4(input.pos, 0.0, 1.0);
output.pos.xy = output.pos.xy * cpos.zw + cpos.xy; output.tex = input.tex;
output.pos.xy = output.pos.xy * 2.0 - 1.0; output.col = input.col;
output.pos.y = -output.pos.y;
output.tex = input.pos * ctex.zw + ctex.xy;
output.col = constants.col;
return output; return output;
} }
+5 -12
View File
@@ -1,9 +1,7 @@
#[set(everything)] #[set(everything)]
const constants: { const constants: {
pos: float4; // xywh empty: float4;
tex: float4; // xywh
col: float4;
channel: int; channel: int;
}; };
@@ -15,6 +13,8 @@ const tex: tex2d;
struct vert_in { struct vert_in {
pos: float2; pos: float2;
tex: float2;
col: float4;
} }
struct vert_out { struct vert_out {
@@ -25,16 +25,9 @@ struct vert_out {
fun layer_view_vert(input: vert_in): vert_out { fun layer_view_vert(input: vert_in): vert_out {
var output: vert_out; var output: vert_out;
var cpos: float4 = constants.pos;
var ctex: float4 = constants.tex;
output.pos = float4(input.pos, 0.0, 1.0); output.pos = float4(input.pos, 0.0, 1.0);
output.pos.xy = output.pos.xy * cpos.zw + cpos.xy; output.tex = input.tex;
output.pos.xy = output.pos.xy * 2.0 - 1.0; output.col = input.col;
output.pos.y = -output.pos.y;
output.tex = input.pos * ctex.zw + ctex.xy;
output.col = constants.col;
return output; return output;
} }
+1 -1
View File
@@ -99,7 +99,7 @@ void import_envmap_run(char *path, gpu_texture_t *image) {
import_envmap_pipeline->blend_source = GPU_BLEND_SOURCE_ALPHA; import_envmap_pipeline->blend_source = GPU_BLEND_SOURCE_ALPHA;
import_envmap_pipeline->blend_destination = GPU_BLEND_ONE; import_envmap_pipeline->blend_destination = GPU_BLEND_ONE;
gpu_vertex_structure_t *vs = GC_ALLOC_INIT(gpu_vertex_structure_t, {0}); gpu_vertex_structure_t *vs = GC_ALLOC_INIT(gpu_vertex_structure_t, {0});
gpu_vertex_struct_add(vs, "pos", GPU_VERTEX_DATA_F32_2X); gpu_vertex_structure_add(vs, "pos", GPU_VERTEX_DATA_F32_2X);
import_envmap_pipeline->input_layout = vs; import_envmap_pipeline->input_layout = vs;
import_envmap_pipeline->color_attachment_count = 1; import_envmap_pipeline->color_attachment_count = 1;
import_envmap_pipeline->color_attachment[0] = GPU_TEXTURE_FORMAT_RGBA64; import_envmap_pipeline->color_attachment[0] = GPU_TEXTURE_FORMAT_RGBA64;
+28 -14
View File
@@ -6,7 +6,7 @@ gpu_pipeline_t *_pipes_make_merge(bool red, bool green, bool blue, bool alpha) {
pipe->vertex_shader = sys_get_shader("layer_merge.vert"); pipe->vertex_shader = sys_get_shader("layer_merge.vert");
pipe->fragment_shader = sys_get_shader("layer_merge.frag"); pipe->fragment_shader = sys_get_shader("layer_merge.frag");
gpu_vertex_structure_t *vs = GC_ALLOC_INIT(gpu_vertex_structure_t, {0}); gpu_vertex_structure_t *vs = GC_ALLOC_INIT(gpu_vertex_structure_t, {0});
gpu_vertex_struct_add(vs, "pos", GPU_VERTEX_DATA_F32_2X); gpu_vertex_structure_add(vs, "pos", GPU_VERTEX_DATA_F32_2X);
pipe->input_layout = vs; pipe->input_layout = vs;
pipe->color_write_mask_red[0] = red; pipe->color_write_mask_red[0] = red;
pipe->color_write_mask_green[0] = green; pipe->color_write_mask_green[0] = green;
@@ -45,7 +45,9 @@ void pipes_init() {
pipes_copy->vertex_shader = sys_get_shader("layer_copy.vert"); pipes_copy->vertex_shader = sys_get_shader("layer_copy.vert");
pipes_copy->fragment_shader = sys_get_shader("layer_copy.frag"); pipes_copy->fragment_shader = sys_get_shader("layer_copy.frag");
gpu_vertex_structure_t *vs = GC_ALLOC_INIT(gpu_vertex_structure_t, {0}); gpu_vertex_structure_t *vs = GC_ALLOC_INIT(gpu_vertex_structure_t, {0});
gpu_vertex_struct_add(vs, "pos", GPU_VERTEX_DATA_F32_2X); gpu_vertex_structure_add(vs, "pos", GPU_VERTEX_DATA_F32_2X);
gpu_vertex_structure_add(vs, "tex", GPU_VERTEX_DATA_F32_2X);
gpu_vertex_structure_add(vs, "col", GPU_VERTEX_DATA_F32_4X);
pipes_copy->input_layout = vs; pipes_copy->input_layout = vs;
gpu_pipeline_compile(pipes_copy); gpu_pipeline_compile(pipes_copy);
} }
@@ -57,7 +59,9 @@ void pipes_init() {
pipes_copy_bgra->vertex_shader = sys_get_shader("layer_copy_bgra.vert"); pipes_copy_bgra->vertex_shader = sys_get_shader("layer_copy_bgra.vert");
pipes_copy_bgra->fragment_shader = sys_get_shader("layer_copy_bgra.frag"); pipes_copy_bgra->fragment_shader = sys_get_shader("layer_copy_bgra.frag");
gpu_vertex_structure_t *vs = GC_ALLOC_INIT(gpu_vertex_structure_t, {0}); gpu_vertex_structure_t *vs = GC_ALLOC_INIT(gpu_vertex_structure_t, {0});
gpu_vertex_struct_add(vs, "pos", GPU_VERTEX_DATA_F32_2X); gpu_vertex_structure_add(vs, "pos", GPU_VERTEX_DATA_F32_2X);
gpu_vertex_structure_add(vs, "tex", GPU_VERTEX_DATA_F32_2X);
gpu_vertex_structure_add(vs, "col", GPU_VERTEX_DATA_F32_4X);
pipes_copy_bgra->input_layout = vs; pipes_copy_bgra->input_layout = vs;
gpu_pipeline_compile(pipes_copy_bgra); gpu_pipeline_compile(pipes_copy_bgra);
} }
@@ -69,7 +73,9 @@ void pipes_init() {
pipes_copy8->vertex_shader = sys_get_shader("layer_copy.vert"); pipes_copy8->vertex_shader = sys_get_shader("layer_copy.vert");
pipes_copy8->fragment_shader = sys_get_shader("layer_copy.frag"); pipes_copy8->fragment_shader = sys_get_shader("layer_copy.frag");
gpu_vertex_structure_t *vs = GC_ALLOC_INIT(gpu_vertex_structure_t, {0}); gpu_vertex_structure_t *vs = GC_ALLOC_INIT(gpu_vertex_structure_t, {0});
gpu_vertex_struct_add(vs, "pos", GPU_VERTEX_DATA_F32_2X); gpu_vertex_structure_add(vs, "pos", GPU_VERTEX_DATA_F32_2X);
gpu_vertex_structure_add(vs, "tex", GPU_VERTEX_DATA_F32_2X);
gpu_vertex_structure_add(vs, "col", GPU_VERTEX_DATA_F32_4X);
pipes_copy8->input_layout = vs; pipes_copy8->input_layout = vs;
pipes_copy8->color_attachment_count = 1; pipes_copy8->color_attachment_count = 1;
pipes_copy8->color_attachment[0] = GPU_TEXTURE_FORMAT_R8; pipes_copy8->color_attachment[0] = GPU_TEXTURE_FORMAT_R8;
@@ -83,7 +89,9 @@ void pipes_init() {
pipes_copy64->vertex_shader = sys_get_shader("layer_copy.vert"); pipes_copy64->vertex_shader = sys_get_shader("layer_copy.vert");
pipes_copy64->fragment_shader = sys_get_shader("layer_copy.frag"); pipes_copy64->fragment_shader = sys_get_shader("layer_copy.frag");
gpu_vertex_structure_t *vs = GC_ALLOC_INIT(gpu_vertex_structure_t, {0}); gpu_vertex_structure_t *vs = GC_ALLOC_INIT(gpu_vertex_structure_t, {0});
gpu_vertex_struct_add(vs, "pos", GPU_VERTEX_DATA_F32_2X); gpu_vertex_structure_add(vs, "pos", GPU_VERTEX_DATA_F32_2X);
gpu_vertex_structure_add(vs, "tex", GPU_VERTEX_DATA_F32_2X);
gpu_vertex_structure_add(vs, "col", GPU_VERTEX_DATA_F32_4X);
pipes_copy64->input_layout = vs; pipes_copy64->input_layout = vs;
pipes_copy64->color_attachment_count = 1; pipes_copy64->color_attachment_count = 1;
pipes_copy64->color_attachment[0] = GPU_TEXTURE_FORMAT_RGBA64; pipes_copy64->color_attachment[0] = GPU_TEXTURE_FORMAT_RGBA64;
@@ -97,7 +105,9 @@ void pipes_init() {
pipes_copy128->vertex_shader = sys_get_shader("layer_copy.vert"); pipes_copy128->vertex_shader = sys_get_shader("layer_copy.vert");
pipes_copy128->fragment_shader = sys_get_shader("layer_copy.frag"); pipes_copy128->fragment_shader = sys_get_shader("layer_copy.frag");
gpu_vertex_structure_t *vs = GC_ALLOC_INIT(gpu_vertex_structure_t, {0}); gpu_vertex_structure_t *vs = GC_ALLOC_INIT(gpu_vertex_structure_t, {0});
gpu_vertex_struct_add(vs, "pos", GPU_VERTEX_DATA_F32_2X); gpu_vertex_structure_add(vs, "pos", GPU_VERTEX_DATA_F32_2X);
gpu_vertex_structure_add(vs, "tex", GPU_VERTEX_DATA_F32_2X);
gpu_vertex_structure_add(vs, "col", GPU_VERTEX_DATA_F32_4X);
pipes_copy128->input_layout = vs; pipes_copy128->input_layout = vs;
pipes_copy128->color_attachment_count = 1; pipes_copy128->color_attachment_count = 1;
pipes_copy128->color_attachment[0] = GPU_TEXTURE_FORMAT_RGBA128; pipes_copy128->color_attachment[0] = GPU_TEXTURE_FORMAT_RGBA128;
@@ -111,7 +121,9 @@ void pipes_init() {
pipes_invert8->vertex_shader = sys_get_shader("layer_invert.vert"); pipes_invert8->vertex_shader = sys_get_shader("layer_invert.vert");
pipes_invert8->fragment_shader = sys_get_shader("layer_invert.frag"); pipes_invert8->fragment_shader = sys_get_shader("layer_invert.frag");
gpu_vertex_structure_t *vs = GC_ALLOC_INIT(gpu_vertex_structure_t, {0}); gpu_vertex_structure_t *vs = GC_ALLOC_INIT(gpu_vertex_structure_t, {0});
gpu_vertex_struct_add(vs, "pos", GPU_VERTEX_DATA_F32_2X); gpu_vertex_structure_add(vs, "pos", GPU_VERTEX_DATA_F32_2X);
gpu_vertex_structure_add(vs, "tex", GPU_VERTEX_DATA_F32_2X);
gpu_vertex_structure_add(vs, "col", GPU_VERTEX_DATA_F32_4X);
pipes_invert8->input_layout = vs; pipes_invert8->input_layout = vs;
pipes_invert8->color_attachment_count = 1; pipes_invert8->color_attachment_count = 1;
pipes_invert8->color_attachment[0] = GPU_TEXTURE_FORMAT_R8; pipes_invert8->color_attachment[0] = GPU_TEXTURE_FORMAT_R8;
@@ -125,7 +137,7 @@ void pipes_init() {
pipes_apply_mask->vertex_shader = sys_get_shader("mask_apply.vert"); pipes_apply_mask->vertex_shader = sys_get_shader("mask_apply.vert");
pipes_apply_mask->fragment_shader = sys_get_shader("mask_apply.frag"); pipes_apply_mask->fragment_shader = sys_get_shader("mask_apply.frag");
gpu_vertex_structure_t *vs = GC_ALLOC_INIT(gpu_vertex_structure_t, {0}); gpu_vertex_structure_t *vs = GC_ALLOC_INIT(gpu_vertex_structure_t, {0});
gpu_vertex_struct_add(vs, "pos", GPU_VERTEX_DATA_F32_2X); gpu_vertex_structure_add(vs, "pos", GPU_VERTEX_DATA_F32_2X);
pipes_apply_mask->input_layout = vs; pipes_apply_mask->input_layout = vs;
gpu_pipeline_compile(pipes_apply_mask); gpu_pipeline_compile(pipes_apply_mask);
pipes_tex0_mask = 0; pipes_tex0_mask = 0;
@@ -139,7 +151,7 @@ void pipes_init() {
pipes_merge_mask->vertex_shader = sys_get_shader("mask_merge.vert"); pipes_merge_mask->vertex_shader = sys_get_shader("mask_merge.vert");
pipes_merge_mask->fragment_shader = sys_get_shader("mask_merge.frag"); pipes_merge_mask->fragment_shader = sys_get_shader("mask_merge.frag");
gpu_vertex_structure_t *vs = GC_ALLOC_INIT(gpu_vertex_structure_t, {0}); gpu_vertex_structure_t *vs = GC_ALLOC_INIT(gpu_vertex_structure_t, {0});
gpu_vertex_struct_add(vs, "pos", GPU_VERTEX_DATA_F32_2X); gpu_vertex_structure_add(vs, "pos", GPU_VERTEX_DATA_F32_2X);
pipes_merge_mask->input_layout = vs; pipes_merge_mask->input_layout = vs;
gpu_pipeline_compile(pipes_merge_mask); gpu_pipeline_compile(pipes_merge_mask);
pipes_tex0_merge_mask = 0; pipes_tex0_merge_mask = 0;
@@ -156,7 +168,7 @@ void pipes_init() {
pipes_colorid_to_mask->vertex_shader = sys_get_shader("mask_colorid.vert"); pipes_colorid_to_mask->vertex_shader = sys_get_shader("mask_colorid.vert");
pipes_colorid_to_mask->fragment_shader = sys_get_shader("mask_colorid.frag"); pipes_colorid_to_mask->fragment_shader = sys_get_shader("mask_colorid.frag");
gpu_vertex_structure_t *vs = GC_ALLOC_INIT(gpu_vertex_structure_t, {0}); gpu_vertex_structure_t *vs = GC_ALLOC_INIT(gpu_vertex_structure_t, {0});
gpu_vertex_struct_add(vs, "pos", GPU_VERTEX_DATA_F32_2X); gpu_vertex_structure_add(vs, "pos", GPU_VERTEX_DATA_F32_2X);
pipes_colorid_to_mask->input_layout = vs; pipes_colorid_to_mask->input_layout = vs;
gpu_pipeline_compile(pipes_colorid_to_mask); gpu_pipeline_compile(pipes_colorid_to_mask);
pipes_texpaint_colorid = 0; pipes_texpaint_colorid = 0;
@@ -170,7 +182,9 @@ void pipes_init() {
pipes_copy_rgb->vertex_shader = sys_get_shader("layer_copy.vert"); pipes_copy_rgb->vertex_shader = sys_get_shader("layer_copy.vert");
pipes_copy_rgb->fragment_shader = sys_get_shader("layer_copy.frag"); pipes_copy_rgb->fragment_shader = sys_get_shader("layer_copy.frag");
gpu_vertex_structure_t *vs = GC_ALLOC_INIT(gpu_vertex_structure_t, {0}); gpu_vertex_structure_t *vs = GC_ALLOC_INIT(gpu_vertex_structure_t, {0});
gpu_vertex_struct_add(vs, "pos", GPU_VERTEX_DATA_F32_2X); gpu_vertex_structure_add(vs, "pos", GPU_VERTEX_DATA_F32_2X);
gpu_vertex_structure_add(vs, "tex", GPU_VERTEX_DATA_F32_2X);
gpu_vertex_structure_add(vs, "col", GPU_VERTEX_DATA_F32_4X);
pipes_copy_rgb->input_layout = vs; pipes_copy_rgb->input_layout = vs;
pipes_copy_rgb->color_write_mask_alpha[0] = false; pipes_copy_rgb->color_write_mask_alpha[0] = false;
gpu_pipeline_compile(pipes_copy_rgb); gpu_pipeline_compile(pipes_copy_rgb);
@@ -183,9 +197,9 @@ void pipes_init() {
pipes_cursor->vertex_shader = sys_get_shader("cursor.vert"); pipes_cursor->vertex_shader = sys_get_shader("cursor.vert");
pipes_cursor->fragment_shader = sys_get_shader("cursor.frag"); pipes_cursor->fragment_shader = sys_get_shader("cursor.frag");
gpu_vertex_structure_t *vs = GC_ALLOC_INIT(gpu_vertex_structure_t, {0}); gpu_vertex_structure_t *vs = GC_ALLOC_INIT(gpu_vertex_structure_t, {0});
gpu_vertex_struct_add(vs, "pos", GPU_VERTEX_DATA_I16_4X_NORM); gpu_vertex_structure_add(vs, "pos", GPU_VERTEX_DATA_I16_4X_NORM);
gpu_vertex_struct_add(vs, "nor", GPU_VERTEX_DATA_I16_2X_NORM); gpu_vertex_structure_add(vs, "nor", GPU_VERTEX_DATA_I16_2X_NORM);
gpu_vertex_struct_add(vs, "tex", GPU_VERTEX_DATA_I16_2X_NORM); gpu_vertex_structure_add(vs, "tex", GPU_VERTEX_DATA_I16_2X_NORM);
pipes_cursor->input_layout = vs; pipes_cursor->input_layout = vs;
pipes_cursor->blend_source = GPU_BLEND_SOURCE_ALPHA; pipes_cursor->blend_source = GPU_BLEND_SOURCE_ALPHA;
pipes_cursor->blend_destination = GPU_BLEND_INV_SOURCE_ALPHA; pipes_cursor->blend_destination = GPU_BLEND_INV_SOURCE_ALPHA;
+4 -4
View File
@@ -21,16 +21,16 @@ void ui_view2d_init() {
ui_view2d_pipe->vertex_shader = sys_get_shader("layer_view.vert"); ui_view2d_pipe->vertex_shader = sys_get_shader("layer_view.vert");
ui_view2d_pipe->fragment_shader = sys_get_shader("layer_view.frag"); ui_view2d_pipe->fragment_shader = sys_get_shader("layer_view.frag");
gpu_vertex_structure_t *vs = GC_ALLOC_INIT(gpu_vertex_structure_t, {0}); gpu_vertex_structure_t *vs = GC_ALLOC_INIT(gpu_vertex_structure_t, {0});
gpu_vertex_struct_add(vs, "pos", GPU_VERTEX_DATA_F32_2X); gpu_vertex_structure_add(vs, "pos", GPU_VERTEX_DATA_F32_2X);
gpu_vertex_structure_add(vs, "tex", GPU_VERTEX_DATA_F32_2X);
gpu_vertex_structure_add(vs, "col", GPU_VERTEX_DATA_F32_4X);
ui_view2d_pipe->input_layout = vs; ui_view2d_pipe->input_layout = vs;
ui_view2d_pipe->blend_source = GPU_BLEND_ONE; ui_view2d_pipe->blend_source = GPU_BLEND_ONE;
ui_view2d_pipe->blend_destination = GPU_BLEND_ZERO; ui_view2d_pipe->blend_destination = GPU_BLEND_ZERO;
ui_view2d_pipe->color_write_mask_alpha[0] = false; ui_view2d_pipe->color_write_mask_alpha[0] = false;
gpu_pipeline_compile(ui_view2d_pipe); gpu_pipeline_compile(ui_view2d_pipe);
pipes_offset = 0; pipes_offset = 0;
pipes_get_constant_location("float4"); pipes_get_constant_location("float4"); // empty
pipes_get_constant_location("float4");
pipes_get_constant_location("float4");
ui_view2d_channel_loc = pipes_get_constant_location("int"); ui_view2d_channel_loc = pipes_get_constant_location("int");
} }
+10 -10
View File
@@ -474,26 +474,26 @@ void util_render_create_screen_aligned_full_data() {
// Mandatory vertex data names and sizes // Mandatory vertex data names and sizes
gpu_vertex_structure_t *structure = GC_ALLOC_INIT(gpu_vertex_structure_t, {0}); gpu_vertex_structure_t *structure = GC_ALLOC_INIT(gpu_vertex_structure_t, {0});
gpu_vertex_struct_add(structure, "pos", GPU_VERTEX_DATA_I16_4X_NORM); gpu_vertex_structure_add(structure, "pos", GPU_VERTEX_DATA_I16_4X_NORM);
gpu_vertex_struct_add(structure, "nor", GPU_VERTEX_DATA_I16_2X_NORM); gpu_vertex_structure_add(structure, "nor", GPU_VERTEX_DATA_I16_2X_NORM);
gpu_vertex_struct_add(structure, "tex", GPU_VERTEX_DATA_I16_2X_NORM); gpu_vertex_structure_add(structure, "tex", GPU_VERTEX_DATA_I16_2X_NORM);
gpu_vertex_struct_add(structure, "col", GPU_VERTEX_DATA_I16_4X_NORM); gpu_vertex_structure_add(structure, "col", GPU_VERTEX_DATA_I16_4X_NORM);
gc_unroot(util_render_screen_aligned_full_vb); gc_unroot(util_render_screen_aligned_full_vb);
util_render_screen_aligned_full_vb = util_render_screen_aligned_full_vb =
gpu_create_vertex_buffer(math_floor(data->length / (float)math_floor(gpu_vertex_struct_size(structure) / 2.0)), structure); gpu_create_vertex_buffer(math_floor(data->length / (float)math_floor(gpu_vertex_struct_size(structure) / 2.0)), structure);
gc_root(util_render_screen_aligned_full_vb); gc_root(util_render_screen_aligned_full_vb);
buffer_t *vertices = gpu_lock_vertex_buffer(util_render_screen_aligned_full_vb); int16_t *vertices = gpu_vertex_buffer_lock(util_render_screen_aligned_full_vb);
for (i32 i = 0; i < math_floor((vertices->length) / 2.0); ++i) { for (i32 i = 0; i < data->length; ++i) {
buffer_set_i16(vertices, i * 2, data->buffer[i]); vertices[i] = data->buffer[i];
} }
gpu_vertex_buffer_unlock(util_render_screen_aligned_full_vb); gpu_vertex_buffer_unlock(util_render_screen_aligned_full_vb);
gc_unroot(util_render_screen_aligned_full_ib); gc_unroot(util_render_screen_aligned_full_ib);
util_render_screen_aligned_full_ib = gpu_create_index_buffer(indices->length); util_render_screen_aligned_full_ib = gpu_create_index_buffer(indices->length);
gc_root(util_render_screen_aligned_full_ib); gc_root(util_render_screen_aligned_full_ib);
u32_array_t *id = gpu_lock_index_buffer(util_render_screen_aligned_full_ib); uint32_t *id = gpu_index_buffer_lock(util_render_screen_aligned_full_ib);
for (i32 i = 0; i < id->length; ++i) { for (i32 i = 0; i < indices->length; ++i) {
id->buffer[i] = indices->buffer[i]; id[i] = indices->buffer[i];
} }
gpu_index_buffer_unlock(util_render_screen_aligned_full_ib); gpu_index_buffer_unlock(util_render_screen_aligned_full_ib);
} }
+3 -3
View File
@@ -116,9 +116,9 @@ void util_uv_cache_dilate_map() {
util_uv_pipe_dilate->vertex_shader = sys_get_shader("dilate_map.vert"); util_uv_pipe_dilate->vertex_shader = sys_get_shader("dilate_map.vert");
util_uv_pipe_dilate->fragment_shader = sys_get_shader("dilate_map.frag"); util_uv_pipe_dilate->fragment_shader = sys_get_shader("dilate_map.frag");
gpu_vertex_structure_t *vs = GC_ALLOC_INIT(gpu_vertex_structure_t, {0}); gpu_vertex_structure_t *vs = GC_ALLOC_INIT(gpu_vertex_structure_t, {0});
gpu_vertex_struct_add(vs, "pos", GPU_VERTEX_DATA_I16_4X_NORM); gpu_vertex_structure_add(vs, "pos", GPU_VERTEX_DATA_I16_4X_NORM);
gpu_vertex_struct_add(vs, "nor", GPU_VERTEX_DATA_I16_2X_NORM); gpu_vertex_structure_add(vs, "nor", GPU_VERTEX_DATA_I16_2X_NORM);
gpu_vertex_struct_add(vs, "tex", GPU_VERTEX_DATA_I16_2X_NORM); gpu_vertex_structure_add(vs, "tex", GPU_VERTEX_DATA_I16_2X_NORM);
util_uv_pipe_dilate->input_layout = vs; util_uv_pipe_dilate->input_layout = vs;
util_uv_pipe_dilate->depth_write = false; util_uv_pipe_dilate->depth_write = false;
util_uv_pipe_dilate->depth_mode = GPU_COMPARE_MODE_ALWAYS; util_uv_pipe_dilate->depth_mode = GPU_COMPARE_MODE_ALWAYS;