remvoing ve_ prefix from glsl and generated odin code, not necessary to have

This commit is contained in:
2025-02-13 16:13:29 -05:00
parent d806fc6083
commit 1ed9d48a71
7 changed files with 1294 additions and 1320 deletions

View File

@@ -59,9 +59,9 @@ setup_gfx_objects :: proc( ctx : ^Context, ve_ctx : ^ve.Context, vert_cap, index
backend := gfx.query_backend()
app_env := glue.environment()
ctx.glyph_shader = gfx.make_shader(ve_render_glyph_shader_desc(backend) )
ctx.atlas_shader = gfx.make_shader(ve_blit_atlas_shader_desc(backend) )
ctx.screen_shader = gfx.make_shader(ve_draw_text_shader_desc(backend) )
ctx.glyph_shader = gfx.make_shader(render_glyph_shader_desc(backend) )
ctx.atlas_shader = gfx.make_shader(blit_atlas_shader_desc(backend) )
ctx.screen_shader = gfx.make_shader(draw_text_shader_desc(backend) )
ctx.draw_list_vbuf = gfx.make_buffer( Buffer_Desciption {
size = cast(uint)(size_of([4]f32) * vert_cap),
@@ -83,12 +83,12 @@ setup_gfx_objects :: proc( ctx : ^Context, ve_ctx : ^ve.Context, vert_cap, index
{
vs_layout : Vertex_Layout_State
{
vs_layout.attrs[ATTR_ve_render_glyph_v_position] = Vertex_Attribute_State {
vs_layout.attrs[ATTR_render_glyph_v_position] = Vertex_Attribute_State {
format = Vertex_Format.FLOAT2,
offset = 0,
buffer_index = 0,
}
vs_layout.attrs[ATTR_ve_render_glyph_v_texture] = Vertex_Attribute_State {
vs_layout.attrs[ATTR_render_glyph_v_texture] = Vertex_Attribute_State {
format = Vertex_Format.FLOAT2,
offset = size_of(ve.Vec2),
buffer_index = 0,
@@ -218,12 +218,12 @@ setup_gfx_objects :: proc( ctx : ^Context, ve_ctx : ^ve.Context, vert_cap, index
{
vs_layout : Vertex_Layout_State
{
vs_layout.attrs[ATTR_ve_blit_atlas_v_position] = Vertex_Attribute_State {
vs_layout.attrs[ATTR_blit_atlas_v_position] = Vertex_Attribute_State {
format = Vertex_Format.FLOAT2,
offset = 0,
buffer_index = 0,
}
vs_layout.attrs[ATTR_ve_blit_atlas_v_texture] = Vertex_Attribute_State {
vs_layout.attrs[ATTR_blit_atlas_v_texture] = Vertex_Attribute_State {
format = Vertex_Format.FLOAT2,
offset = size_of(ve.Vec2),
buffer_index = 0,
@@ -354,12 +354,12 @@ setup_gfx_objects :: proc( ctx : ^Context, ve_ctx : ^ve.Context, vert_cap, index
{
vs_layout : Vertex_Layout_State
{
vs_layout.attrs[ATTR_ve_draw_text_v_position] = Vertex_Attribute_State {
vs_layout.attrs[ATTR_draw_text_v_position] = Vertex_Attribute_State {
format = Vertex_Format.FLOAT2,
offset = 0,
buffer_index = 0,
}
vs_layout.attrs[ATTR_ve_draw_text_v_texture] = Vertex_Attribute_State {
vs_layout.attrs[ATTR_draw_text_v_texture] = Vertex_Attribute_State {
format = Vertex_Format.FLOAT2,
offset = size_of(ve.Vec2),
buffer_index = 0,
@@ -528,12 +528,12 @@ render_text_layer :: proc( screen_extent : ve.Vec2, ve_ctx : ^ve.Context, ctx :
gfx.apply_pipeline( ctx.atlas_pipeline )
fs_uniform := Ve_Blit_Atlas_Fs_Params {
fs_uniform := Blit_Atlas_Fs_Params {
glyph_buffer_size = ve.vec2(ve_ctx.glyph_buffer.size),
over_sample = ve_ctx.glyph_buffer.over_sample.x,
region = cast(i32) draw_call.region,
}
gfx.apply_uniforms( UB_ve_blit_atlas_fs_params, Range { & fs_uniform, size_of(Ve_Blit_Atlas_Fs_Params) })
gfx.apply_uniforms( UB_blit_atlas_fs_params, Range { & fs_uniform, size_of(Blit_Atlas_Fs_Params) })
gfx.apply_bindings(Bindings {
vertex_buffers = {
@@ -544,8 +544,8 @@ render_text_layer :: proc( screen_extent : ve.Vec2, ve_ctx : ^ve.Context, ctx :
},
index_buffer = ctx.draw_list_ibuf,
index_buffer_offset = 0,
images = { IMG_ve_blit_atlas_src_texture = ctx.glyph_rt_color, },
samplers = { SMP_ve_blit_atlas_src_sampler = ctx.glyph_rt_sampler, },
images = { IMG_blit_atlas_src_texture = ctx.glyph_rt_color, },
samplers = { SMP_blit_atlas_src_sampler = ctx.glyph_rt_sampler, },
})
// 3. Use the atlas (.Target) or the glyph buffer (.Target_Unchached) to then render the text.
@@ -568,7 +568,7 @@ render_text_layer :: proc( screen_extent : ve.Vec2, ve_ctx : ^ve.Context, ctx :
src_rt := ctx.atlas_rt_color
src_sampler := ctx.atlas_rt_sampler
fs_target_uniform := Ve_Draw_Text_Fs_Params {
fs_target_uniform := Draw_Text_Fs_Params {
// glyph_buffer_size = glyph_buf_size,
over_sample = ve_ctx.glyph_buffer.over_sample.x,
colour = draw_call.colour,
@@ -579,7 +579,7 @@ render_text_layer :: proc( screen_extent : ve.Vec2, ve_ctx : ^ve.Context, ctx :
src_rt = ctx.glyph_rt_color
src_sampler = ctx.glyph_rt_sampler
}
gfx.apply_uniforms( UB_ve_draw_text_fs_params, Range { & fs_target_uniform, size_of(Ve_Draw_Text_Fs_Params) })
gfx.apply_uniforms( UB_draw_text_fs_params, Range { & fs_target_uniform, size_of(Draw_Text_Fs_Params) })
gfx.apply_bindings(Bindings {
vertex_buffers = {
@@ -590,8 +590,8 @@ render_text_layer :: proc( screen_extent : ve.Vec2, ve_ctx : ^ve.Context, ctx :
},
index_buffer = ctx.draw_list_ibuf,
index_buffer_offset = 0,
images = { IMG_ve_draw_text_src_texture = src_rt, },
samplers = { SMP_ve_draw_text_src_sampler = src_sampler, },
images = { IMG_draw_text_src_texture = src_rt, },
samplers = { SMP_draw_text_src_sampler = src_sampler, },
})
}

File diff suppressed because it is too large Load Diff

View File

@@ -12,10 +12,10 @@
in vec2 uv;
out vec4 frag_color;
layout(binding = 0) uniform texture2D ve_blit_atlas_src_texture;
layout(binding = 0) uniform sampler ve_blit_atlas_src_sampler;
layout(binding = 0) uniform texture2D blit_atlas_src_texture;
layout(binding = 0) uniform sampler blit_atlas_src_sampler;
layout(binding = 0) uniform ve_blit_atlas_fs_params {
layout(binding = 0) uniform blit_atlas_fs_params {
vec2 glyph_buffer_size;
float over_sample;
int region;
@@ -26,10 +26,10 @@ float down_sample_to_texture( vec2 uv, vec2 texture_size )
float down_sample = 1.0f / over_sample;
float value =
texture(sampler2D( ve_blit_atlas_src_texture, ve_blit_atlas_src_sampler ), uv + vec2( 0.0f, 0.0f ) * texture_size ).x * down_sample
+ texture(sampler2D( ve_blit_atlas_src_texture, ve_blit_atlas_src_sampler ), uv + vec2( 0.0f, 1.0f ) * texture_size ).x * down_sample
+ texture(sampler2D( ve_blit_atlas_src_texture, ve_blit_atlas_src_sampler ), uv + vec2( 1.0f, 0.0f ) * texture_size ).x * down_sample
+ texture(sampler2D( ve_blit_atlas_src_texture, ve_blit_atlas_src_sampler ), uv + vec2( 1.0f, 1.0f ) * texture_size ).x * down_sample;
texture(sampler2D( blit_atlas_src_texture, blit_atlas_src_sampler ), uv + vec2( 0.0f, 0.0f ) * texture_size ).x * down_sample
+ texture(sampler2D( blit_atlas_src_texture, blit_atlas_src_sampler ), uv + vec2( 0.0f, 1.0f ) * texture_size ).x * down_sample
+ texture(sampler2D( blit_atlas_src_texture, blit_atlas_src_sampler ), uv + vec2( 1.0f, 0.0f ) * texture_size ).x * down_sample
+ texture(sampler2D( blit_atlas_src_texture, blit_atlas_src_sampler ), uv + vec2( 1.0f, 1.0f ) * texture_size ).x * down_sample;
return value;
}
@@ -55,4 +55,4 @@ void main()
}
@end
@program ve_blit_atlas blit_atlas_vs blit_atlas_fs
@program blit_atlas blit_atlas_vs blit_atlas_fs

File diff suppressed because it is too large Load Diff

View File

@@ -4,7 +4,7 @@
@header package ve_sokol
@header import sg "thirdparty:sokol/gfx"
@vs ve_draw_text_vs
@vs draw_text_vs
in vec2 v_position;
in vec2 v_texture;
out vec2 uv;
@@ -20,14 +20,14 @@ void main()
}
@end
@fs ve_draw_text_fs
@fs draw_text_fs
in vec2 uv;
out vec4 frag_color;
layout(binding = 0) uniform texture2D ve_draw_text_src_texture;
layout(binding = 0) uniform sampler ve_draw_text_src_sampler;
layout(binding = 0) uniform texture2D draw_text_src_texture;
layout(binding = 0) uniform sampler draw_text_src_sampler;
layout(binding = 0) uniform ve_draw_text_fs_params {
layout(binding = 0) uniform draw_text_fs_params {
vec2 glyph_buffer_size;
float over_sample;
vec4 colour;
@@ -35,18 +35,18 @@ layout(binding = 0) uniform ve_draw_text_fs_params {
void main()
{
float alpha = texture(sampler2D( ve_draw_text_src_texture, ve_draw_text_src_sampler ), uv ).x;
float alpha = texture(sampler2D( draw_text_src_texture, draw_text_src_sampler ), uv ).x;
const vec2 texture_size = glyph_buffer_size;
const float down_sample = 1.0f / over_sample;
alpha =
(texture(sampler2D( ve_draw_text_src_texture, ve_draw_text_src_sampler), uv + vec2( -0.5f, -0.5f) * texture_size ).x * down_sample)
+ (texture(sampler2D( ve_draw_text_src_texture, ve_draw_text_src_sampler), uv + vec2( -0.5f, 0.5f) * texture_size ).x * down_sample)
+ (texture(sampler2D( ve_draw_text_src_texture, ve_draw_text_src_sampler), uv + vec2( 0.5f, -0.5f) * texture_size ).x * down_sample)
+ (texture(sampler2D( ve_draw_text_src_texture, ve_draw_text_src_sampler), uv + vec2( 0.5f, 0.5f) * texture_size ).x * down_sample);
(texture(sampler2D( draw_text_src_texture, draw_text_src_sampler), uv + vec2( -0.5f, -0.5f) * texture_size ).x * down_sample)
+ (texture(sampler2D( draw_text_src_texture, draw_text_src_sampler), uv + vec2( -0.5f, 0.5f) * texture_size ).x * down_sample)
+ (texture(sampler2D( draw_text_src_texture, draw_text_src_sampler), uv + vec2( 0.5f, -0.5f) * texture_size ).x * down_sample)
+ (texture(sampler2D( draw_text_src_texture, draw_text_src_sampler), uv + vec2( 0.5f, 0.5f) * texture_size ).x * down_sample);
frag_color = vec4( colour.xyz, colour.a * alpha );
}
@end
@program ve_draw_text ve_draw_text_vs ve_draw_text_fs
@program draw_text draw_text_vs draw_text_fs

View File

@@ -10,17 +10,17 @@ import sg "thirdparty:sokol/gfx"
Overview:
=========
Shader program: 've_render_glyph':
Get shader desc: ve_render_glyph_shader_desc(sg.query_backend())
Shader program: 'render_glyph':
Get shader desc: render_glyph_shader_desc(sg.query_backend())
Vertex Shader: render_glyph_vs
Fragment Shader: render_glyph_fs
Attributes:
ATTR_ve_render_glyph_v_position => 0
ATTR_ve_render_glyph_v_texture => 1
ATTR_render_glyph_v_position => 0
ATTR_render_glyph_v_texture => 1
Bindings:
*/
ATTR_ve_render_glyph_v_position :: 0
ATTR_ve_render_glyph_v_texture :: 1
ATTR_render_glyph_v_position :: 0
ATTR_render_glyph_v_texture :: 1
/*
#version 410
@@ -509,9 +509,9 @@ render_glyph_fs_source_wgsl := [361]u8 {
0x61,0x69,0x6e,0x5f,0x6f,0x75,0x74,0x28,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,
0x6f,0x72,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
}
ve_render_glyph_shader_desc :: proc (backend: sg.Backend) -> sg.Shader_Desc {
render_glyph_shader_desc :: proc (backend: sg.Backend) -> sg.Shader_Desc {
desc: sg.Shader_Desc
desc.label = "ve_render_glyph_shader"
desc.label = "render_glyph_shader"
#partial switch backend {
case .GLCORE:
desc.vertex_func.source = transmute(cstring)&render_glyph_vs_source_glsl410

View File

@@ -18,4 +18,4 @@ void main()
}
@end
@program ve_render_glyph render_glyph_vs render_glyph_fs
@program render_glyph render_glyph_vs render_glyph_fs