diff --git a/code/grime/logger.odin b/code/grime/logger.odin index 807cb98..e05d76a 100644 --- a/code/grime/logger.odin +++ b/code/grime/logger.odin @@ -83,7 +83,7 @@ logger_interface :: proc( str_fmt_builder( & builder, "] ") } } - core_log.do_level_header( options, level, & builder ) + core_log.do_level_header( options, & builder, level ) if logger.id != "" { str_fmt_builder( & builder, "[%s] ", logger.id ) diff --git a/code/sectr/font/.raw_provider.odin b/code/sectr/font/.simple_provider.odin similarity index 100% rename from code/sectr/font/.raw_provider.odin rename to code/sectr/font/.simple_provider.odin diff --git a/code/sectr/shaders/font_glyph.odin b/code/sectr/shaders/simple_font_glyph.odin similarity index 92% rename from code/sectr/shaders/font_glyph.odin rename to code/sectr/shaders/simple_font_glyph.odin index 5d9e8f7..d341c06 100644 --- a/code/sectr/shaders/font_glyph.odin +++ b/code/sectr/shaders/simple_font_glyph.odin @@ -1,10 +1,12 @@ +package sectr +import sg "thirdparty:sokol/gfx" /* #version:1# (machine generated, don't edit!) Generated by sokol-shdc (https://github.com/floooh/sokol-tools) Cmdline: - sokol-shdc --input C:\projects\SectrPrototype\code\sectr\shaders\font_glyph.shdc.glsl --output C:\projects\SectrPrototype\code\sectr\shaders\font_glyph.odin --slang hlsl5 --format=sokol_odin + sokol-shdc --input C:\projects\SectrPrototype\code\sectr\shaders\simple_font_glyph.shdc.glsl --output C:\projects\SectrPrototype\code\sectr\shaders\simple_font_glyph.odin --slang hlsl5 --format=sokol_odin Overview: ========= @@ -33,17 +35,12 @@ Image: glyph_bitmap Sampler: glyph_bitmap_sampler */ -package sectr -import sg "thirdparty:sokol/gfx" - -ATTR_font_glyph_vs_vertex :: 0 +ATTR_font_glyph_vs_vertex :: 0 ATTR_font_glyph_vs_texture_coord :: 1 - SLOT_font_glyph_vs_params :: 0 SLOT_font_glyph_fs_params :: 0 -SLOT_glyph_bitmap :: 0 +SLOT_glyph_bitmap :: 0 SLOT_glyph_bitmap_sampler :: 0 - Font_Glyph_Vs_Params :: struct #align(16) { using _: struct #packed { projection: [16]f32, @@ -240,30 +237,24 @@ font_glyph_shader_desc :: proc (backend: sg.Backend) -> sg.Shader_Desc { desc.attrs[0].sem_index = 0 desc.attrs[1].sem_name = "TEXCOORD" desc.attrs[1].sem_index = 1 - - desc.vs.source = transmute(cstring)&font_glyph_vs_source_hlsl5 - desc.vs.d3d11_target = "vs_5_0" - desc.vs.entry = "main" - desc.vs.uniform_blocks[0].size = 64 + desc.vs.source = transmute(cstring)&font_glyph_vs_source_hlsl5 + desc.vs.d3d11_target = "vs_5_0" + desc.vs.entry = "main" + desc.vs.uniform_blocks[0].size = 64 desc.vs.uniform_blocks[0].layout = .STD140 - - desc.fs.source = transmute(cstring)&font_glyph_fs_source_hlsl5 - desc.fs.d3d11_target = "ps_5_0" - desc.fs.entry = "main" - - desc.fs.uniform_blocks[0].size = 16 + desc.fs.source = transmute(cstring)&font_glyph_fs_source_hlsl5 + desc.fs.d3d11_target = "ps_5_0" + desc.fs.entry = "main" + desc.fs.uniform_blocks[0].size = 16 desc.fs.uniform_blocks[0].layout = .STD140 - - desc.fs.images[0].used = true + desc.fs.images[0].used = true desc.fs.images[0].multisampled = false - desc.fs.images[0].image_type = ._2D - desc.fs.images[0].sample_type = .FLOAT - - desc.fs.samplers[0].used = true + desc.fs.images[0].image_type = ._2D + desc.fs.images[0].sample_type = .FLOAT + desc.fs.samplers[0].used = true desc.fs.samplers[0].sampler_type = .FILTERING - - desc.fs.image_sampler_pairs[0].used = true - desc.fs.image_sampler_pairs[0].image_slot = 0 + desc.fs.image_sampler_pairs[0].used = true + desc.fs.image_sampler_pairs[0].image_slot = 0 desc.fs.image_sampler_pairs[0].sampler_slot = 0 } return desc diff --git a/code/sectr/shaders/font_glyph.shdc.glsl b/code/sectr/shaders/simple_font_glyph.shdc.glsl similarity index 90% rename from code/sectr/shaders/font_glyph.shdc.glsl rename to code/sectr/shaders/simple_font_glyph.shdc.glsl index ebe05fd..612eae1 100644 --- a/code/sectr/shaders/font_glyph.shdc.glsl +++ b/code/sectr/shaders/simple_font_glyph.shdc.glsl @@ -1,3 +1,6 @@ +@header package sectr +@header import sg "thirdparty:sokol/gfx" + @vs font_glyph_vs in vec2 vertex; in vec2 texture_coord; diff --git a/code/sectr/shaders/ve_blit_atlas.odin b/code/sectr/shaders/ve_blit_atlas.odin new file mode 100644 index 0000000..063cca9 --- /dev/null +++ b/code/sectr/shaders/ve_blit_atlas.odin @@ -0,0 +1,370 @@ +package sectr +import sg "thirdparty:sokol/gfx" +/* + #version:1# (machine generated, don't edit!) + + Generated by sokol-shdc (https://github.com/floooh/sokol-tools) + + Cmdline: + sokol-shdc --input C:\projects\SectrPrototype\code\sectr\shaders\ve_blit_atlas.shdc.glsl --output C:\projects\SectrPrototype\code\sectr\shaders\ve_blit_atlas.odin --slang hlsl5 --format=sokol_odin --module =vefc_blit_atlas + + Overview: + ========= + Shader program: 'vefc_blit_atlas': + Get shader desc: vefc_blit_atlas_shader_desc(sg.query_backend()) + Vertex shader: vefc_blit_atlas_vs + Attributes: + ATTR_vefc_blit_atlas_vs_v_position => 0 + ATTR_vefc_blit_atlas_vs_v_texture => 1 + Fragment shader: vefc_blit_atlas_fs + Uniform block 'vefc_blit_atlas_fs_params': + Odin struct: Vefc_Blit_Atlas_Fs_Params + Bind slot: SLOT_vefc_blit_atlas_fs_params => 0 + Image 'vefc_blit_atlas_src_texture': + Image type: ._2D + Sample type: .FLOAT + Multisampled: false + Bind slot: SLOT_vefc_blit_atlas_src_texture => 0 + Sampler 'vefc_blit_atlas_src_sampler': + Type: .FILTERING + Bind slot: SLOT_vefc_blit_atlas_src_sampler => 0 + Image Sampler Pair 'vefc_blit_atlas_src_texture_vefc_blit_atlas_src_sampler': + Image: vefc_blit_atlas_src_texture + Sampler: vefc_blit_atlas_src_sampler +*/ +ATTR_vefc_blit_atlas_vs_v_position :: 0 +ATTR_vefc_blit_atlas_vs_v_texture :: 1 +SLOT_vefc_blit_atlas_fs_params :: 0 +SLOT_vefc_blit_atlas_src_texture :: 0 +SLOT_vefc_blit_atlas_src_sampler :: 0 +Vefc_Blit_Atlas_Fs_Params :: struct #align(16) { + using _: struct #packed { + region: i32, + _: [12]u8, + }, +} +/* + static float4 gl_Position; + static float2 uv; + static float2 v_texture; + static float2 v_position; + + struct SPIRV_Cross_Input + { + float2 v_position : TEXCOORD0; + float2 v_texture : TEXCOORD1; + }; + + struct SPIRV_Cross_Output + { + float2 uv : TEXCOORD0; + float4 gl_Position : SV_Position; + }; + + void vert_main() + { + uv = v_texture; + gl_Position = float4(v_position, 0.0f, 1.0f); + } + + SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) + { + v_texture = stage_input.v_texture; + v_position = stage_input.v_position; + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + stage_output.uv = uv; + return stage_output; + } +*/ +@(private) +vefc_blit_atlas_vs_source_hlsl5 := [675]u8 { + 0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c, + 0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69, + 0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x75,0x76,0x3b,0x0a,0x73,0x74,0x61, + 0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x76,0x5f,0x74,0x65,0x78, + 0x74,0x75,0x72,0x65,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f, + 0x61,0x74,0x32,0x20,0x76,0x5f,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a, + 0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72, + 0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20, + 0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x76,0x5f,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f, + 0x6e,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x30,0x3b,0x0a,0x20, + 0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x76,0x5f,0x74,0x65,0x78,0x74, + 0x75,0x72,0x65,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x31,0x3b, + 0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52, + 0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x0a,0x7b, + 0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x75,0x76,0x20,0x3a, + 0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69, + 0x6f,0x6e,0x20,0x3a,0x20,0x53,0x56,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e, + 0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x76,0x65,0x72,0x74,0x5f, + 0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x75,0x76,0x20, + 0x3d,0x20,0x76,0x5f,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x66, + 0x6c,0x6f,0x61,0x74,0x34,0x28,0x76,0x5f,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e, + 0x2c,0x20,0x30,0x2e,0x30,0x66,0x2c,0x20,0x31,0x2e,0x30,0x66,0x29,0x3b,0x0a,0x7d, + 0x0a,0x0a,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75, + 0x74,0x70,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x28,0x53,0x50,0x49,0x52,0x56,0x5f, + 0x43,0x72,0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,0x20,0x73,0x74,0x61,0x67, + 0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x76, + 0x5f,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x20,0x3d,0x20,0x73,0x74,0x61,0x67,0x65, + 0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,0x76,0x5f,0x74,0x65,0x78,0x74,0x75,0x72,0x65, + 0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x5f,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e, + 0x20,0x3d,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,0x76, + 0x5f,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76, + 0x65,0x72,0x74,0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70, + 0x75,0x74,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75, + 0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20, + 0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x2e,0x75,0x76, + 0x20,0x3d,0x20,0x75,0x76,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72, + 0x6e,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a, + 0x7d,0x0a,0x00, +} +/* + cbuffer vefc_blit_atlas_fs_params : register(b0) + { + int _83_region : packoffset(c0); + }; + + Texture2D vefc_blit_atlas_src_texture : register(t0); + SamplerState vefc_blit_atlas_src_sampler : register(s0); + + static float2 uv; + static float4 frag_color; + + struct SPIRV_Cross_Input + { + float2 uv : TEXCOORD0; + }; + + struct SPIRV_Cross_Output + { + float4 frag_color : SV_Target0; + }; + + float down_sample(float2 uv_1, float2 texture_size) + { + return 0.25f * (((vefc_blit_atlas_src_texture.Sample(vefc_blit_atlas_src_sampler, uv_1).x + vefc_blit_atlas_src_texture.Sample(vefc_blit_atlas_src_sampler, mad(float2(0.0f, 1.0f), texture_size, uv_1)).x) + vefc_blit_atlas_src_texture.Sample(vefc_blit_atlas_src_sampler, mad(float2(1.0f, 0.0f), texture_size, uv_1)).x) + vefc_blit_atlas_src_texture.Sample(vefc_blit_atlas_src_sampler, uv_1 + texture_size).x); + } + + void frag_main() + { + uint _88 = uint(_83_region); + bool _89 = _88 == 0u; + bool _98; + if (!_89) + { + _98 = _88 == 1u; + } + else + { + _98 = _89; + } + bool _107; + if (!_98) + { + _107 = _88 == 2u; + } + else + { + _107 = _98; + } + if (_107) + { + float2 param = uv + float2(-0.00048828125f, -0.0029296875f); + float2 param_1 = float2(0.00048828125f, 0.001953125f); + float2 param_2 = uv + float2(0.000244140625f, -0.0029296875f); + float2 param_3 = float2(0.00048828125f, 0.001953125f); + float2 param_4 = uv + float2(-0.000732421875f, 0.0009765625f); + float2 param_5 = float2(0.00048828125f, 0.001953125f); + float2 param_6 = uv + float2(0.000244140625f, 0.0009765625f); + float2 param_7 = float2(0.00048828125f, 0.001953125f); + frag_color = float4(1.0f, 1.0f, 1.0f, 0.25f * (((down_sample(param, param_1) + down_sample(param_2, param_3)) + down_sample(param_4, param_5)) + down_sample(param_6, param_7))); + } + else + { + frag_color = float4(0.0f, 0.0f, 0.0f, 1.0f); + } + } + + SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) + { + uv = stage_input.uv; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.frag_color = frag_color; + return stage_output; + } +*/ +@(private) +vefc_blit_atlas_fs_source_hlsl5 := [2172]u8 { + 0x63,0x62,0x75,0x66,0x66,0x65,0x72,0x20,0x76,0x65,0x66,0x63,0x5f,0x62,0x6c,0x69, + 0x74,0x5f,0x61,0x74,0x6c,0x61,0x73,0x5f,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d, + 0x73,0x20,0x3a,0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x28,0x62,0x30,0x29, + 0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x5f,0x38,0x33,0x5f,0x72, + 0x65,0x67,0x69,0x6f,0x6e,0x20,0x3a,0x20,0x70,0x61,0x63,0x6b,0x6f,0x66,0x66,0x73, + 0x65,0x74,0x28,0x63,0x30,0x29,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x54,0x65,0x78,0x74, + 0x75,0x72,0x65,0x32,0x44,0x3c,0x66,0x6c,0x6f,0x61,0x74,0x34,0x3e,0x20,0x76,0x65, + 0x66,0x63,0x5f,0x62,0x6c,0x69,0x74,0x5f,0x61,0x74,0x6c,0x61,0x73,0x5f,0x73,0x72, + 0x63,0x5f,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x20,0x3a,0x20,0x72,0x65,0x67,0x69, + 0x73,0x74,0x65,0x72,0x28,0x74,0x30,0x29,0x3b,0x0a,0x53,0x61,0x6d,0x70,0x6c,0x65, + 0x72,0x53,0x74,0x61,0x74,0x65,0x20,0x76,0x65,0x66,0x63,0x5f,0x62,0x6c,0x69,0x74, + 0x5f,0x61,0x74,0x6c,0x61,0x73,0x5f,0x73,0x72,0x63,0x5f,0x73,0x61,0x6d,0x70,0x6c, + 0x65,0x72,0x20,0x3a,0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x28,0x73,0x30, + 0x29,0x3b,0x0a,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74, + 0x32,0x20,0x75,0x76,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f, + 0x61,0x74,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a, + 0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72, + 0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20, + 0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x75,0x76,0x20,0x3a,0x20,0x54,0x45,0x58,0x43, + 0x4f,0x4f,0x52,0x44,0x30,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63, + 0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75, + 0x74,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74, + 0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3a,0x20,0x53, + 0x56,0x5f,0x54,0x61,0x72,0x67,0x65,0x74,0x30,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x66, + 0x6c,0x6f,0x61,0x74,0x20,0x64,0x6f,0x77,0x6e,0x5f,0x73,0x61,0x6d,0x70,0x6c,0x65, + 0x28,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x75,0x76,0x5f,0x31,0x2c,0x20,0x66,0x6c, + 0x6f,0x61,0x74,0x32,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x5f,0x73,0x69,0x7a, + 0x65,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20, + 0x30,0x2e,0x32,0x35,0x66,0x20,0x2a,0x20,0x28,0x28,0x28,0x76,0x65,0x66,0x63,0x5f, + 0x62,0x6c,0x69,0x74,0x5f,0x61,0x74,0x6c,0x61,0x73,0x5f,0x73,0x72,0x63,0x5f,0x74, + 0x65,0x78,0x74,0x75,0x72,0x65,0x2e,0x53,0x61,0x6d,0x70,0x6c,0x65,0x28,0x76,0x65, + 0x66,0x63,0x5f,0x62,0x6c,0x69,0x74,0x5f,0x61,0x74,0x6c,0x61,0x73,0x5f,0x73,0x72, + 0x63,0x5f,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x2c,0x20,0x75,0x76,0x5f,0x31,0x29, + 0x2e,0x78,0x20,0x2b,0x20,0x76,0x65,0x66,0x63,0x5f,0x62,0x6c,0x69,0x74,0x5f,0x61, + 0x74,0x6c,0x61,0x73,0x5f,0x73,0x72,0x63,0x5f,0x74,0x65,0x78,0x74,0x75,0x72,0x65, + 0x2e,0x53,0x61,0x6d,0x70,0x6c,0x65,0x28,0x76,0x65,0x66,0x63,0x5f,0x62,0x6c,0x69, + 0x74,0x5f,0x61,0x74,0x6c,0x61,0x73,0x5f,0x73,0x72,0x63,0x5f,0x73,0x61,0x6d,0x70, + 0x6c,0x65,0x72,0x2c,0x20,0x6d,0x61,0x64,0x28,0x66,0x6c,0x6f,0x61,0x74,0x32,0x28, + 0x30,0x2e,0x30,0x66,0x2c,0x20,0x31,0x2e,0x30,0x66,0x29,0x2c,0x20,0x74,0x65,0x78, + 0x74,0x75,0x72,0x65,0x5f,0x73,0x69,0x7a,0x65,0x2c,0x20,0x75,0x76,0x5f,0x31,0x29, + 0x29,0x2e,0x78,0x29,0x20,0x2b,0x20,0x76,0x65,0x66,0x63,0x5f,0x62,0x6c,0x69,0x74, + 0x5f,0x61,0x74,0x6c,0x61,0x73,0x5f,0x73,0x72,0x63,0x5f,0x74,0x65,0x78,0x74,0x75, + 0x72,0x65,0x2e,0x53,0x61,0x6d,0x70,0x6c,0x65,0x28,0x76,0x65,0x66,0x63,0x5f,0x62, + 0x6c,0x69,0x74,0x5f,0x61,0x74,0x6c,0x61,0x73,0x5f,0x73,0x72,0x63,0x5f,0x73,0x61, + 0x6d,0x70,0x6c,0x65,0x72,0x2c,0x20,0x6d,0x61,0x64,0x28,0x66,0x6c,0x6f,0x61,0x74, + 0x32,0x28,0x31,0x2e,0x30,0x66,0x2c,0x20,0x30,0x2e,0x30,0x66,0x29,0x2c,0x20,0x74, + 0x65,0x78,0x74,0x75,0x72,0x65,0x5f,0x73,0x69,0x7a,0x65,0x2c,0x20,0x75,0x76,0x5f, + 0x31,0x29,0x29,0x2e,0x78,0x29,0x20,0x2b,0x20,0x76,0x65,0x66,0x63,0x5f,0x62,0x6c, + 0x69,0x74,0x5f,0x61,0x74,0x6c,0x61,0x73,0x5f,0x73,0x72,0x63,0x5f,0x74,0x65,0x78, + 0x74,0x75,0x72,0x65,0x2e,0x53,0x61,0x6d,0x70,0x6c,0x65,0x28,0x76,0x65,0x66,0x63, + 0x5f,0x62,0x6c,0x69,0x74,0x5f,0x61,0x74,0x6c,0x61,0x73,0x5f,0x73,0x72,0x63,0x5f, + 0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x2c,0x20,0x75,0x76,0x5f,0x31,0x20,0x2b,0x20, + 0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x5f,0x73,0x69,0x7a,0x65,0x29,0x2e,0x78,0x29, + 0x3b,0x0a,0x7d,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x66,0x72,0x61,0x67,0x5f,0x6d, + 0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x75,0x69,0x6e,0x74, + 0x20,0x5f,0x38,0x38,0x20,0x3d,0x20,0x75,0x69,0x6e,0x74,0x28,0x5f,0x38,0x33,0x5f, + 0x72,0x65,0x67,0x69,0x6f,0x6e,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x62,0x6f,0x6f, + 0x6c,0x20,0x5f,0x38,0x39,0x20,0x3d,0x20,0x5f,0x38,0x38,0x20,0x3d,0x3d,0x20,0x30, + 0x75,0x3b,0x0a,0x20,0x20,0x20,0x20,0x62,0x6f,0x6f,0x6c,0x20,0x5f,0x39,0x38,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x21,0x5f,0x38,0x39,0x29,0x0a,0x20, + 0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x39,0x38, + 0x20,0x3d,0x20,0x5f,0x38,0x38,0x20,0x3d,0x3d,0x20,0x31,0x75,0x3b,0x0a,0x20,0x20, + 0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20, + 0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x39,0x38,0x20,0x3d, + 0x20,0x5f,0x38,0x39,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20, + 0x62,0x6f,0x6f,0x6c,0x20,0x5f,0x31,0x30,0x37,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69, + 0x66,0x20,0x28,0x21,0x5f,0x39,0x38,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x31,0x30,0x37,0x20,0x3d,0x20,0x5f,0x38, + 0x38,0x20,0x3d,0x3d,0x20,0x32,0x75,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20, + 0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x31,0x30,0x37,0x20,0x3d,0x20,0x5f,0x39,0x38, + 0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28, + 0x5f,0x31,0x30,0x37,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x70,0x61,0x72,0x61,0x6d, + 0x20,0x3d,0x20,0x75,0x76,0x20,0x2b,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x28,0x2d, + 0x30,0x2e,0x30,0x30,0x30,0x34,0x38,0x38,0x32,0x38,0x31,0x32,0x35,0x66,0x2c,0x20, + 0x2d,0x30,0x2e,0x30,0x30,0x32,0x39,0x32,0x39,0x36,0x38,0x37,0x35,0x66,0x29,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20, + 0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32, + 0x28,0x30,0x2e,0x30,0x30,0x30,0x34,0x38,0x38,0x32,0x38,0x31,0x32,0x35,0x66,0x2c, + 0x20,0x30,0x2e,0x30,0x30,0x31,0x39,0x35,0x33,0x31,0x32,0x35,0x66,0x29,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x70, + 0x61,0x72,0x61,0x6d,0x5f,0x32,0x20,0x3d,0x20,0x75,0x76,0x20,0x2b,0x20,0x66,0x6c, + 0x6f,0x61,0x74,0x32,0x28,0x30,0x2e,0x30,0x30,0x30,0x32,0x34,0x34,0x31,0x34,0x30, + 0x36,0x32,0x35,0x66,0x2c,0x20,0x2d,0x30,0x2e,0x30,0x30,0x32,0x39,0x32,0x39,0x36, + 0x38,0x37,0x35,0x66,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66, + 0x6c,0x6f,0x61,0x74,0x32,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x20,0x3d,0x20, + 0x66,0x6c,0x6f,0x61,0x74,0x32,0x28,0x30,0x2e,0x30,0x30,0x30,0x34,0x38,0x38,0x32, + 0x38,0x31,0x32,0x35,0x66,0x2c,0x20,0x30,0x2e,0x30,0x30,0x31,0x39,0x35,0x33,0x31, + 0x32,0x35,0x66,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c, + 0x6f,0x61,0x74,0x32,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x34,0x20,0x3d,0x20,0x75, + 0x76,0x20,0x2b,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x28,0x2d,0x30,0x2e,0x30,0x30, + 0x30,0x37,0x33,0x32,0x34,0x32,0x31,0x38,0x37,0x35,0x66,0x2c,0x20,0x30,0x2e,0x30, + 0x30,0x30,0x39,0x37,0x36,0x35,0x36,0x32,0x35,0x66,0x29,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x70,0x61,0x72,0x61, + 0x6d,0x5f,0x35,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x28,0x30,0x2e,0x30, + 0x30,0x30,0x34,0x38,0x38,0x32,0x38,0x31,0x32,0x35,0x66,0x2c,0x20,0x30,0x2e,0x30, + 0x30,0x31,0x39,0x35,0x33,0x31,0x32,0x35,0x66,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x70,0x61,0x72,0x61,0x6d, + 0x5f,0x36,0x20,0x3d,0x20,0x75,0x76,0x20,0x2b,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32, + 0x28,0x30,0x2e,0x30,0x30,0x30,0x32,0x34,0x34,0x31,0x34,0x30,0x36,0x32,0x35,0x66, + 0x2c,0x20,0x30,0x2e,0x30,0x30,0x30,0x39,0x37,0x36,0x35,0x36,0x32,0x35,0x66,0x29, + 0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32, + 0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x37,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74, + 0x32,0x28,0x30,0x2e,0x30,0x30,0x30,0x34,0x38,0x38,0x32,0x38,0x31,0x32,0x35,0x66, + 0x2c,0x20,0x30,0x2e,0x30,0x30,0x31,0x39,0x35,0x33,0x31,0x32,0x35,0x66,0x29,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f, + 0x6c,0x6f,0x72,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x31,0x2e,0x30, + 0x66,0x2c,0x20,0x31,0x2e,0x30,0x66,0x2c,0x20,0x31,0x2e,0x30,0x66,0x2c,0x20,0x30, + 0x2e,0x32,0x35,0x66,0x20,0x2a,0x20,0x28,0x28,0x28,0x64,0x6f,0x77,0x6e,0x5f,0x73, + 0x61,0x6d,0x70,0x6c,0x65,0x28,0x70,0x61,0x72,0x61,0x6d,0x2c,0x20,0x70,0x61,0x72, + 0x61,0x6d,0x5f,0x31,0x29,0x20,0x2b,0x20,0x64,0x6f,0x77,0x6e,0x5f,0x73,0x61,0x6d, + 0x70,0x6c,0x65,0x28,0x70,0x61,0x72,0x61,0x6d,0x5f,0x32,0x2c,0x20,0x70,0x61,0x72, + 0x61,0x6d,0x5f,0x33,0x29,0x29,0x20,0x2b,0x20,0x64,0x6f,0x77,0x6e,0x5f,0x73,0x61, + 0x6d,0x70,0x6c,0x65,0x28,0x70,0x61,0x72,0x61,0x6d,0x5f,0x34,0x2c,0x20,0x70,0x61, + 0x72,0x61,0x6d,0x5f,0x35,0x29,0x29,0x20,0x2b,0x20,0x64,0x6f,0x77,0x6e,0x5f,0x73, + 0x61,0x6d,0x70,0x6c,0x65,0x28,0x70,0x61,0x72,0x61,0x6d,0x5f,0x36,0x2c,0x20,0x70, + 0x61,0x72,0x61,0x6d,0x5f,0x37,0x29,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d, + 0x0a,0x20,0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c, + 0x6f,0x72,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x30,0x2e,0x30,0x66, + 0x2c,0x20,0x30,0x2e,0x30,0x66,0x2c,0x20,0x30,0x2e,0x30,0x66,0x2c,0x20,0x31,0x2e, + 0x30,0x66,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x7d,0x0a,0x0a,0x53,0x50, + 0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74, + 0x20,0x6d,0x61,0x69,0x6e,0x28,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73, + 0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e, + 0x70,0x75,0x74,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x75,0x76,0x20,0x3d,0x20, + 0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,0x75,0x76,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73, + 0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75, + 0x74,0x70,0x75,0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,0x73,0x74,0x61,0x67,0x65,0x5f, + 0x6f,0x75,0x74,0x70,0x75,0x74,0x2e,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f, + 0x72,0x20,0x3d,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x73,0x74,0x61,0x67,0x65, + 0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x00, +} +vefc_blit_atlas_shader_desc :: proc (backend: sg.Backend) -> sg.Shader_Desc { + desc: sg.Shader_Desc + desc.label = "vefc_blit_atlas_shader" + #partial switch backend { + case .D3D11: + desc.attrs[0].sem_name = "TEXCOORD" + desc.attrs[0].sem_index = 0 + desc.attrs[1].sem_name = "TEXCOORD" + desc.attrs[1].sem_index = 1 + desc.vs.source = transmute(cstring)&vefc_blit_atlas_vs_source_hlsl5 + desc.vs.d3d11_target = "vs_5_0" + desc.vs.entry = "main" + desc.fs.source = transmute(cstring)&vefc_blit_atlas_fs_source_hlsl5 + desc.fs.d3d11_target = "ps_5_0" + desc.fs.entry = "main" + desc.fs.uniform_blocks[0].size = 16 + desc.fs.uniform_blocks[0].layout = .STD140 + desc.fs.images[0].used = true + desc.fs.images[0].multisampled = false + desc.fs.images[0].image_type = ._2D + desc.fs.images[0].sample_type = .FLOAT + desc.fs.samplers[0].used = true + desc.fs.samplers[0].sampler_type = .FILTERING + desc.fs.image_sampler_pairs[0].used = true + desc.fs.image_sampler_pairs[0].image_slot = 0 + desc.fs.image_sampler_pairs[0].sampler_slot = 0 + } + return desc +} diff --git a/code/sectr/shaders/ve_blit_atlas.shdc.glsl b/code/sectr/shaders/ve_blit_atlas.shdc.glsl new file mode 100644 index 0000000..a1aab57 --- /dev/null +++ b/code/sectr/shaders/ve_blit_atlas.shdc.glsl @@ -0,0 +1,51 @@ +@module vefc_blit_atlas + +@header package sectr +@header import sg "thirdparty:sokol/gfx" + +@vs vefc_blit_atlas_vs +@include ./ve_source_shared.shdc.glsl +@end + +@fs vefc_blit_atlas_fs +in vec2 uv; +out vec4 frag_color; + +uniform texture2D vefc_blit_atlas_src_texture; +uniform sampler vefc_blit_atlas_src_sampler; + +uniform vefc_blit_atlas_fs_params { + int region; +}; + +float down_sample( vec2 uv, vec2 texture_size ) +{ + float value = + texture(sampler2D( vefc_blit_atlas_src_texture, vefc_blit_atlas_src_sampler ), uv + vec2( 0.0, 0.0 ) * texture_size ).x * 0.25 + + texture(sampler2D( vefc_blit_atlas_src_texture, vefc_blit_atlas_src_sampler ), uv + vec2( 0.0, 1.0 ) * texture_size ).x * 0.25 + + texture(sampler2D( vefc_blit_atlas_src_texture, vefc_blit_atlas_src_sampler ), uv + vec2( 1.0, 0.0 ) * texture_size ).x * 0.25 + + texture(sampler2D( vefc_blit_atlas_src_texture, vefc_blit_atlas_src_sampler ), uv + vec2( 1.0, 1.0 ) * texture_size ).x * 0.25; + return value; +} + +void main() +{ + // TODO(Ed): The original author made these consts, I want to instead expose as uniforms... + const vec2 texture_size = 1.0 / vec2( 2048, 512 ); // VEFontCache.Context.buffer_width/buffer_height + if ( region == 0u || region == 1u || region == 2u ) + { + float alpha = + down_sample( uv + vec2( -1.0, -1.5 ) * texture_size, texture_size ) * 0.25 + + down_sample( uv + vec2( 0.5, -1.5 ) * texture_size, texture_size ) * 0.25 + + down_sample( uv + vec2( -1.5, 0.5 ) * texture_size, texture_size ) * 0.25 + + down_sample( uv + vec2( 0.5, 0.5 ) * texture_size, texture_size ) * 0.25; + frag_color = vec4( 1.0, 1.0, 1.0, alpha ); + } + else + { + frag_color = vec4( 0, 0, 0, 1.0 ); + } +} +@end + +@program vefc_blit_atlas vefc_blit_atlas_vs vefc_blit_atlas_fs diff --git a/code/sectr/shaders/ve_draw_text.odin b/code/sectr/shaders/ve_draw_text.odin new file mode 100644 index 0000000..bfa93f6 --- /dev/null +++ b/code/sectr/shaders/ve_draw_text.odin @@ -0,0 +1,286 @@ +package sectr +import sg "thirdparty:sokol/gfx" +/* + #version:1# (machine generated, don't edit!) + + Generated by sokol-shdc (https://github.com/floooh/sokol-tools) + + Cmdline: + sokol-shdc --input C:\projects\SectrPrototype\code\sectr\shaders\ve_draw_text.shdc.glsl --output C:\projects\SectrPrototype\code\sectr\shaders\ve_draw_text.odin --slang hlsl5 --format=sokol_odin --module =vefc_draw_text + + Overview: + ========= + Shader program: 'vefc_draw_text': + Get shader desc: vefc_draw_text_shader_desc(sg.query_backend()) + Vertex shader: vefc_draw_text_vs + Attributes: + ATTR_vefc_draw_text_vs_v_position => 0 + ATTR_vefc_draw_text_vs_v_texture => 1 + Fragment shader: vefc_draw_text_fs + Uniform block 'vefc_draw_text_fs_params': + Odin struct: Vefc_Draw_Text_Fs_Params + Bind slot: SLOT_vefc_draw_text_fs_params => 0 + Image 'vefc_draw_text_src_texture': + Image type: ._2D + Sample type: .FLOAT + Multisampled: false + Bind slot: SLOT_vefc_draw_text_src_texture => 0 + Sampler 'vefc_draw_text_src_sampler': + Type: .FILTERING + Bind slot: SLOT_vefc_draw_text_src_sampler => 0 + Image Sampler Pair 'vefc_draw_text_src_texture_vefc_draw_text_src_sampler': + Image: vefc_draw_text_src_texture + Sampler: vefc_draw_text_src_sampler +*/ +ATTR_vefc_draw_text_vs_v_position :: 0 +ATTR_vefc_draw_text_vs_v_texture :: 1 +SLOT_vefc_draw_text_fs_params :: 0 +SLOT_vefc_draw_text_src_texture :: 0 +SLOT_vefc_draw_text_src_sampler :: 0 +Vefc_Draw_Text_Fs_Params :: struct #align(16) { + using _: struct #packed { + down_sample: i32, + _: [12]u8, + colour: [4]f32, + }, +} +/* + static float4 gl_Position; + static float2 uv; + static float2 v_texture; + static float2 v_position; + + struct SPIRV_Cross_Input + { + float2 v_position : TEXCOORD0; + float2 v_texture : TEXCOORD1; + }; + + struct SPIRV_Cross_Output + { + float2 uv : TEXCOORD0; + float4 gl_Position : SV_Position; + }; + + void vert_main() + { + uv = v_texture; + gl_Position = float4((v_position * 2.0f) - 1.0f.xx, 0.0f, 1.0f); + } + + SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) + { + v_texture = stage_input.v_texture; + v_position = stage_input.v_position; + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + stage_output.uv = uv; + return stage_output; + } +*/ +@(private) +vefc_draw_text_vs_source_hlsl5 := [694]u8 { + 0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c, + 0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69, + 0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x75,0x76,0x3b,0x0a,0x73,0x74,0x61, + 0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x76,0x5f,0x74,0x65,0x78, + 0x74,0x75,0x72,0x65,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f, + 0x61,0x74,0x32,0x20,0x76,0x5f,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a, + 0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72, + 0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20, + 0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x76,0x5f,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f, + 0x6e,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x30,0x3b,0x0a,0x20, + 0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x76,0x5f,0x74,0x65,0x78,0x74, + 0x75,0x72,0x65,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x31,0x3b, + 0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52, + 0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x0a,0x7b, + 0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x75,0x76,0x20,0x3a, + 0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69, + 0x6f,0x6e,0x20,0x3a,0x20,0x53,0x56,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e, + 0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x76,0x65,0x72,0x74,0x5f, + 0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x75,0x76,0x20, + 0x3d,0x20,0x76,0x5f,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x66, + 0x6c,0x6f,0x61,0x74,0x34,0x28,0x28,0x76,0x5f,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f, + 0x6e,0x20,0x2a,0x20,0x32,0x2e,0x30,0x66,0x29,0x20,0x2d,0x20,0x31,0x2e,0x30,0x66, + 0x2e,0x78,0x78,0x2c,0x20,0x30,0x2e,0x30,0x66,0x2c,0x20,0x31,0x2e,0x30,0x66,0x29, + 0x3b,0x0a,0x7d,0x0a,0x0a,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73, + 0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x28,0x53,0x50,0x49, + 0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,0x20,0x73, + 0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x29,0x0a,0x7b,0x0a,0x20,0x20, + 0x20,0x20,0x76,0x5f,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x20,0x3d,0x20,0x73,0x74, + 0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,0x76,0x5f,0x74,0x65,0x78,0x74, + 0x75,0x72,0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x5f,0x70,0x6f,0x73,0x69,0x74, + 0x69,0x6f,0x6e,0x20,0x3d,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75, + 0x74,0x2e,0x76,0x5f,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20, + 0x20,0x20,0x76,0x65,0x72,0x74,0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29,0x3b,0x0a,0x20, + 0x20,0x20,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f, + 0x75,0x74,0x70,0x75,0x74,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70, + 0x75,0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75, + 0x74,0x70,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e, + 0x20,0x3d,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74, + 0x2e,0x75,0x76,0x20,0x3d,0x20,0x75,0x76,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65, + 0x74,0x75,0x72,0x6e,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75, + 0x74,0x3b,0x0a,0x7d,0x0a,0x00, +} +/* + cbuffer vefc_draw_text_fs_params : register(b0) + { + int _31_down_sample : packoffset(c0); + float4 _31_colour : packoffset(c1); + }; + + Texture2D vefc_draw_text_src_texture : register(t0); + SamplerState vefc_draw_text_src_sampler : register(s0); + + static float2 uv; + static float4 frag_color; + + struct SPIRV_Cross_Input + { + float2 uv : TEXCOORD0; + }; + + struct SPIRV_Cross_Output + { + float4 frag_color : SV_Target0; + }; + + void frag_main() + { + float alpha = vefc_draw_text_src_texture.Sample(vefc_draw_text_src_sampler, uv).x; + if (uint(_31_down_sample) == 1u) + { + alpha = 0.25f * (((vefc_draw_text_src_texture.Sample(vefc_draw_text_src_sampler, uv + float2(-0.000244140625f, -0.0009765625f)).x + vefc_draw_text_src_texture.Sample(vefc_draw_text_src_sampler, uv + float2(-0.000244140625f, 0.0009765625f)).x) + vefc_draw_text_src_texture.Sample(vefc_draw_text_src_sampler, uv + float2(0.000244140625f, -0.0009765625f)).x) + vefc_draw_text_src_texture.Sample(vefc_draw_text_src_sampler, uv + float2(0.000244140625f, 0.0009765625f)).x); + } + frag_color = float4(_31_colour.xyz, _31_colour.w * alpha); + } + + SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) + { + uv = stage_input.uv; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.frag_color = frag_color; + return stage_output; + } +*/ +@(private) +vefc_draw_text_fs_source_hlsl5 := [1329]u8 { + 0x63,0x62,0x75,0x66,0x66,0x65,0x72,0x20,0x76,0x65,0x66,0x63,0x5f,0x64,0x72,0x61, + 0x77,0x5f,0x74,0x65,0x78,0x74,0x5f,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73, + 0x20,0x3a,0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x28,0x62,0x30,0x29,0x0a, + 0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x5f,0x33,0x31,0x5f,0x64,0x6f, + 0x77,0x6e,0x5f,0x73,0x61,0x6d,0x70,0x6c,0x65,0x20,0x3a,0x20,0x70,0x61,0x63,0x6b, + 0x6f,0x66,0x66,0x73,0x65,0x74,0x28,0x63,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x33,0x31,0x5f,0x63,0x6f,0x6c,0x6f,0x75, + 0x72,0x20,0x3a,0x20,0x70,0x61,0x63,0x6b,0x6f,0x66,0x66,0x73,0x65,0x74,0x28,0x63, + 0x31,0x29,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x54,0x65,0x78,0x74,0x75,0x72,0x65,0x32, + 0x44,0x3c,0x66,0x6c,0x6f,0x61,0x74,0x34,0x3e,0x20,0x76,0x65,0x66,0x63,0x5f,0x64, + 0x72,0x61,0x77,0x5f,0x74,0x65,0x78,0x74,0x5f,0x73,0x72,0x63,0x5f,0x74,0x65,0x78, + 0x74,0x75,0x72,0x65,0x20,0x3a,0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x28, + 0x74,0x30,0x29,0x3b,0x0a,0x53,0x61,0x6d,0x70,0x6c,0x65,0x72,0x53,0x74,0x61,0x74, + 0x65,0x20,0x76,0x65,0x66,0x63,0x5f,0x64,0x72,0x61,0x77,0x5f,0x74,0x65,0x78,0x74, + 0x5f,0x73,0x72,0x63,0x5f,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x20,0x3a,0x20,0x72, + 0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x28,0x73,0x30,0x29,0x3b,0x0a,0x0a,0x73,0x74, + 0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x75,0x76,0x3b,0x0a, + 0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x66,0x72, + 0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63, + 0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x49,0x6e, + 0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32, + 0x20,0x75,0x76,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x30,0x3b, + 0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52, + 0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x0a,0x7b, + 0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x66,0x72,0x61,0x67, + 0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3a,0x20,0x53,0x56,0x5f,0x54,0x61,0x72,0x67, + 0x65,0x74,0x30,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x66,0x72, + 0x61,0x67,0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20, + 0x66,0x6c,0x6f,0x61,0x74,0x20,0x61,0x6c,0x70,0x68,0x61,0x20,0x3d,0x20,0x76,0x65, + 0x66,0x63,0x5f,0x64,0x72,0x61,0x77,0x5f,0x74,0x65,0x78,0x74,0x5f,0x73,0x72,0x63, + 0x5f,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x2e,0x53,0x61,0x6d,0x70,0x6c,0x65,0x28, + 0x76,0x65,0x66,0x63,0x5f,0x64,0x72,0x61,0x77,0x5f,0x74,0x65,0x78,0x74,0x5f,0x73, + 0x72,0x63,0x5f,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x2c,0x20,0x75,0x76,0x29,0x2e, + 0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x75,0x69,0x6e,0x74,0x28, + 0x5f,0x33,0x31,0x5f,0x64,0x6f,0x77,0x6e,0x5f,0x73,0x61,0x6d,0x70,0x6c,0x65,0x29, + 0x20,0x3d,0x3d,0x20,0x31,0x75,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x61,0x6c,0x70,0x68,0x61,0x20,0x3d,0x20,0x30,0x2e, + 0x32,0x35,0x66,0x20,0x2a,0x20,0x28,0x28,0x28,0x76,0x65,0x66,0x63,0x5f,0x64,0x72, + 0x61,0x77,0x5f,0x74,0x65,0x78,0x74,0x5f,0x73,0x72,0x63,0x5f,0x74,0x65,0x78,0x74, + 0x75,0x72,0x65,0x2e,0x53,0x61,0x6d,0x70,0x6c,0x65,0x28,0x76,0x65,0x66,0x63,0x5f, + 0x64,0x72,0x61,0x77,0x5f,0x74,0x65,0x78,0x74,0x5f,0x73,0x72,0x63,0x5f,0x73,0x61, + 0x6d,0x70,0x6c,0x65,0x72,0x2c,0x20,0x75,0x76,0x20,0x2b,0x20,0x66,0x6c,0x6f,0x61, + 0x74,0x32,0x28,0x2d,0x30,0x2e,0x30,0x30,0x30,0x32,0x34,0x34,0x31,0x34,0x30,0x36, + 0x32,0x35,0x66,0x2c,0x20,0x2d,0x30,0x2e,0x30,0x30,0x30,0x39,0x37,0x36,0x35,0x36, + 0x32,0x35,0x66,0x29,0x29,0x2e,0x78,0x20,0x2b,0x20,0x76,0x65,0x66,0x63,0x5f,0x64, + 0x72,0x61,0x77,0x5f,0x74,0x65,0x78,0x74,0x5f,0x73,0x72,0x63,0x5f,0x74,0x65,0x78, + 0x74,0x75,0x72,0x65,0x2e,0x53,0x61,0x6d,0x70,0x6c,0x65,0x28,0x76,0x65,0x66,0x63, + 0x5f,0x64,0x72,0x61,0x77,0x5f,0x74,0x65,0x78,0x74,0x5f,0x73,0x72,0x63,0x5f,0x73, + 0x61,0x6d,0x70,0x6c,0x65,0x72,0x2c,0x20,0x75,0x76,0x20,0x2b,0x20,0x66,0x6c,0x6f, + 0x61,0x74,0x32,0x28,0x2d,0x30,0x2e,0x30,0x30,0x30,0x32,0x34,0x34,0x31,0x34,0x30, + 0x36,0x32,0x35,0x66,0x2c,0x20,0x30,0x2e,0x30,0x30,0x30,0x39,0x37,0x36,0x35,0x36, + 0x32,0x35,0x66,0x29,0x29,0x2e,0x78,0x29,0x20,0x2b,0x20,0x76,0x65,0x66,0x63,0x5f, + 0x64,0x72,0x61,0x77,0x5f,0x74,0x65,0x78,0x74,0x5f,0x73,0x72,0x63,0x5f,0x74,0x65, + 0x78,0x74,0x75,0x72,0x65,0x2e,0x53,0x61,0x6d,0x70,0x6c,0x65,0x28,0x76,0x65,0x66, + 0x63,0x5f,0x64,0x72,0x61,0x77,0x5f,0x74,0x65,0x78,0x74,0x5f,0x73,0x72,0x63,0x5f, + 0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x2c,0x20,0x75,0x76,0x20,0x2b,0x20,0x66,0x6c, + 0x6f,0x61,0x74,0x32,0x28,0x30,0x2e,0x30,0x30,0x30,0x32,0x34,0x34,0x31,0x34,0x30, + 0x36,0x32,0x35,0x66,0x2c,0x20,0x2d,0x30,0x2e,0x30,0x30,0x30,0x39,0x37,0x36,0x35, + 0x36,0x32,0x35,0x66,0x29,0x29,0x2e,0x78,0x29,0x20,0x2b,0x20,0x76,0x65,0x66,0x63, + 0x5f,0x64,0x72,0x61,0x77,0x5f,0x74,0x65,0x78,0x74,0x5f,0x73,0x72,0x63,0x5f,0x74, + 0x65,0x78,0x74,0x75,0x72,0x65,0x2e,0x53,0x61,0x6d,0x70,0x6c,0x65,0x28,0x76,0x65, + 0x66,0x63,0x5f,0x64,0x72,0x61,0x77,0x5f,0x74,0x65,0x78,0x74,0x5f,0x73,0x72,0x63, + 0x5f,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x2c,0x20,0x75,0x76,0x20,0x2b,0x20,0x66, + 0x6c,0x6f,0x61,0x74,0x32,0x28,0x30,0x2e,0x30,0x30,0x30,0x32,0x34,0x34,0x31,0x34, + 0x30,0x36,0x32,0x35,0x66,0x2c,0x20,0x30,0x2e,0x30,0x30,0x30,0x39,0x37,0x36,0x35, + 0x36,0x32,0x35,0x66,0x29,0x29,0x2e,0x78,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d, + 0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20, + 0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x5f,0x33,0x31,0x5f,0x63,0x6f,0x6c, + 0x6f,0x75,0x72,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,0x33,0x31,0x5f,0x63,0x6f,0x6c, + 0x6f,0x75,0x72,0x2e,0x77,0x20,0x2a,0x20,0x61,0x6c,0x70,0x68,0x61,0x29,0x3b,0x0a, + 0x7d,0x0a,0x0a,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f, + 0x75,0x74,0x70,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x28,0x53,0x50,0x49,0x52,0x56, + 0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,0x20,0x73,0x74,0x61, + 0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20, + 0x75,0x76,0x20,0x3d,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74, + 0x2e,0x75,0x76,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x6d,0x61, + 0x69,0x6e,0x28,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x53,0x50,0x49,0x52,0x56,0x5f, + 0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x73,0x74,0x61, + 0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,0x73, + 0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x2e,0x66,0x72,0x61,0x67, + 0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f, + 0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20, + 0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x7d,0x0a, + 0x00, +} +vefc_draw_text_shader_desc :: proc (backend: sg.Backend) -> sg.Shader_Desc { + desc: sg.Shader_Desc + desc.label = "vefc_draw_text_shader" + #partial switch backend { + case .D3D11: + desc.attrs[0].sem_name = "TEXCOORD" + desc.attrs[0].sem_index = 0 + desc.attrs[1].sem_name = "TEXCOORD" + desc.attrs[1].sem_index = 1 + desc.vs.source = transmute(cstring)&vefc_draw_text_vs_source_hlsl5 + desc.vs.d3d11_target = "vs_5_0" + desc.vs.entry = "main" + desc.fs.source = transmute(cstring)&vefc_draw_text_fs_source_hlsl5 + desc.fs.d3d11_target = "ps_5_0" + desc.fs.entry = "main" + desc.fs.uniform_blocks[0].size = 32 + desc.fs.uniform_blocks[0].layout = .STD140 + desc.fs.images[0].used = true + desc.fs.images[0].multisampled = false + desc.fs.images[0].image_type = ._2D + desc.fs.images[0].sample_type = .FLOAT + desc.fs.samplers[0].used = true + desc.fs.samplers[0].sampler_type = .FILTERING + desc.fs.image_sampler_pairs[0].used = true + desc.fs.image_sampler_pairs[0].image_slot = 0 + desc.fs.image_sampler_pairs[0].sampler_slot = 0 + } + return desc +} diff --git a/code/sectr/shaders/ve_draw_text.shdc.glsl b/code/sectr/shaders/ve_draw_text.shdc.glsl new file mode 100644 index 0000000..d3a56a6 --- /dev/null +++ b/code/sectr/shaders/ve_draw_text.shdc.glsl @@ -0,0 +1,48 @@ +@module vefc_draw_text + +@header package sectr +@header import sg "thirdparty:sokol/gfx" + +@vs vefc_draw_text_vs +in vec2 v_position; +in vec2 v_texture; +out vec2 uv; + +void main() +{ + uv = v_texture; + gl_Position = vec4( v_position.xy * 2.0 - 1.0, 0.0, 1.0 ); +} +@end + +@fs vefc_draw_text_fs + +in vec2 uv; +out vec4 frag_color; + +uniform texture2D vefc_draw_text_src_texture; +uniform sampler vefc_draw_text_src_sampler; + +uniform vefc_draw_text_fs_params { + int down_sample; + vec4 colour; +}; + +void main() +{ + float alpha = texture(sampler2D( vefc_draw_text_src_texture, vefc_draw_text_src_sampler ), uv ).x; + if ( down_sample == 1u ) + { + // TODO(Ed): The original author made these consts, I want to instead expose as uniforms... + const vec2 texture_size = 1.0 / vec2( 2048.0, 512.0 ); // VEFontCache.Context.buffer_width/buffer_height + alpha = + texture(sampler2D( vefc_draw_text_src_texture, vefc_draw_text_src_sampler), uv + vec2( -0.5, -0.5) * texture_size ).x * 0.25 + + texture(sampler2D( vefc_draw_text_src_texture, vefc_draw_text_src_sampler), uv + vec2( -0.5, 0.5) * texture_size ).x * 0.25 + + texture(sampler2D( vefc_draw_text_src_texture, vefc_draw_text_src_sampler), uv + vec2( 0.5, -0.5) * texture_size ).x * 0.25 + + texture(sampler2D( vefc_draw_text_src_texture, vefc_draw_text_src_sampler), uv + vec2( 0.5, 0.5) * texture_size ).x * 0.25; + } + frag_color = vec4( colour.xyz, colour.a * alpha ); +} +@end + +@program vefc_draw_text vefc_draw_text_vs vefc_draw_text_fs diff --git a/code/sectr/shaders/ve_render_glyph.odin b/code/sectr/shaders/ve_render_glyph.odin new file mode 100644 index 0000000..8c44ba5 --- /dev/null +++ b/code/sectr/shaders/ve_render_glyph.odin @@ -0,0 +1,179 @@ +package sectr +import sg "thirdparty:sokol/gfx" +/* + #version:1# (machine generated, don't edit!) + + Generated by sokol-shdc (https://github.com/floooh/sokol-tools) + + Cmdline: + sokol-shdc --input C:\projects\SectrPrototype\code\sectr\shaders\ve_render_glyph.shdc.glsl --output C:\projects\SectrPrototype\code\sectr\shaders\ve_render_glyph.odin --slang hlsl5 --format=sokol_odin --module =vefc_render_glyph + + Overview: + ========= + Shader program: 'vefc_render_glyph': + Get shader desc: vefc_render_glyph_shader_desc(sg.query_backend()) + Vertex shader: vefc_render_glyph_vs + Attributes: + ATTR_vefc_render_glyph_vs_v_position => 0 + ATTR_vefc_render_glyph_vs_v_texture => 1 + Fragment shader: vefc_render_glyph_fs +*/ +ATTR_vefc_render_glyph_vs_v_position :: 0 +ATTR_vefc_render_glyph_vs_v_texture :: 1 +/* + static float4 gl_Position; + static float2 uv; + static float2 v_texture; + static float2 v_position; + + struct SPIRV_Cross_Input + { + float2 v_position : TEXCOORD0; + float2 v_texture : TEXCOORD1; + }; + + struct SPIRV_Cross_Output + { + float2 uv : TEXCOORD0; + float4 gl_Position : SV_Position; + }; + + void vert_main() + { + uv = v_texture; + gl_Position = float4(v_position, 0.0f, 1.0f); + } + + SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) + { + v_texture = stage_input.v_texture; + v_position = stage_input.v_position; + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + stage_output.uv = uv; + return stage_output; + } +*/ +@(private) +vefc_render_glyph_vs_source_hlsl5 := [675]u8 { + 0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c, + 0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69, + 0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x75,0x76,0x3b,0x0a,0x73,0x74,0x61, + 0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x76,0x5f,0x74,0x65,0x78, + 0x74,0x75,0x72,0x65,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f, + 0x61,0x74,0x32,0x20,0x76,0x5f,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a, + 0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72, + 0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20, + 0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x76,0x5f,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f, + 0x6e,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x30,0x3b,0x0a,0x20, + 0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x76,0x5f,0x74,0x65,0x78,0x74, + 0x75,0x72,0x65,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x31,0x3b, + 0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52, + 0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x0a,0x7b, + 0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x75,0x76,0x20,0x3a, + 0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69, + 0x6f,0x6e,0x20,0x3a,0x20,0x53,0x56,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e, + 0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x76,0x65,0x72,0x74,0x5f, + 0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x75,0x76,0x20, + 0x3d,0x20,0x76,0x5f,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x66, + 0x6c,0x6f,0x61,0x74,0x34,0x28,0x76,0x5f,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e, + 0x2c,0x20,0x30,0x2e,0x30,0x66,0x2c,0x20,0x31,0x2e,0x30,0x66,0x29,0x3b,0x0a,0x7d, + 0x0a,0x0a,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75, + 0x74,0x70,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x28,0x53,0x50,0x49,0x52,0x56,0x5f, + 0x43,0x72,0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,0x20,0x73,0x74,0x61,0x67, + 0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x76, + 0x5f,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x20,0x3d,0x20,0x73,0x74,0x61,0x67,0x65, + 0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,0x76,0x5f,0x74,0x65,0x78,0x74,0x75,0x72,0x65, + 0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x5f,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e, + 0x20,0x3d,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,0x76, + 0x5f,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76, + 0x65,0x72,0x74,0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70, + 0x75,0x74,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75, + 0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20, + 0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x2e,0x75,0x76, + 0x20,0x3d,0x20,0x75,0x76,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72, + 0x6e,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a, + 0x7d,0x0a,0x00, +} +/* + static float4 frag_color; + static float2 uv; + + struct SPIRV_Cross_Input + { + float2 uv : TEXCOORD0; + }; + + struct SPIRV_Cross_Output + { + float4 frag_color : SV_Target0; + }; + + void frag_main() + { + frag_color = 1.0f.xxxx; + } + + SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) + { + uv = stage_input.uv; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.frag_color = frag_color; + return stage_output; + } +*/ +@(private) +vefc_render_glyph_fs_source_hlsl5 := [427]u8 { + 0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x66,0x72, + 0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63, + 0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x75,0x76,0x3b,0x0a,0x0a,0x73,0x74,0x72, + 0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f, + 0x49,0x6e,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61, + 0x74,0x32,0x20,0x75,0x76,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44, + 0x30,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,0x50, + 0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74, + 0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x66,0x72, + 0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3a,0x20,0x53,0x56,0x5f,0x54,0x61, + 0x72,0x67,0x65,0x74,0x30,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20, + 0x66,0x72,0x61,0x67,0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20, + 0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x31, + 0x2e,0x30,0x66,0x2e,0x78,0x78,0x78,0x78,0x3b,0x0a,0x7d,0x0a,0x0a,0x53,0x50,0x49, + 0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20, + 0x6d,0x61,0x69,0x6e,0x28,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73, + 0x5f,0x49,0x6e,0x70,0x75,0x74,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70, + 0x75,0x74,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x75,0x76,0x20,0x3d,0x20,0x73, + 0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,0x75,0x76,0x3b,0x0a,0x20, + 0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f, + 0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74, + 0x70,0x75,0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f, + 0x75,0x74,0x70,0x75,0x74,0x2e,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72, + 0x20,0x3d,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20, + 0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x73,0x74,0x61,0x67,0x65,0x5f, + 0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x00, +} +vefc_render_glyph_shader_desc :: proc (backend: sg.Backend) -> sg.Shader_Desc { + desc: sg.Shader_Desc + desc.label = "vefc_render_glyph_shader" + #partial switch backend { + case .D3D11: + desc.attrs[0].sem_name = "TEXCOORD" + desc.attrs[0].sem_index = 0 + desc.attrs[1].sem_name = "TEXCOORD" + desc.attrs[1].sem_index = 1 + desc.vs.source = transmute(cstring)&vefc_render_glyph_vs_source_hlsl5 + desc.vs.d3d11_target = "vs_5_0" + desc.vs.entry = "main" + desc.fs.source = transmute(cstring)&vefc_render_glyph_fs_source_hlsl5 + desc.fs.d3d11_target = "ps_5_0" + desc.fs.entry = "main" + } + return desc +} diff --git a/code/sectr/shaders/ve_render_glyph.shdc.glsl b/code/sectr/shaders/ve_render_glyph.shdc.glsl new file mode 100644 index 0000000..4c830fe --- /dev/null +++ b/code/sectr/shaders/ve_render_glyph.shdc.glsl @@ -0,0 +1,20 @@ +@module vefc_render_glyph + +@header package sectr +@header import sg "thirdparty:sokol/gfx" + +@vs vefc_render_glyph_vs +@include ./ve_source_shared.shdc.glsl +@end + +@fs vefc_render_glyph_fs +in vec2 uv; +out vec4 frag_color; + +void main() +{ + frag_color = vec4( 1.0, 1.0, 1.0, 1.0 ); +} +@end + +@program vefc_render_glyph vefc_render_glyph_vs vefc_render_glyph_fs diff --git a/code/sectr/shaders/ve_source_shared.shdc.glsl b/code/sectr/shaders/ve_source_shared.shdc.glsl new file mode 100644 index 0000000..8c158b9 --- /dev/null +++ b/code/sectr/shaders/ve_source_shared.shdc.glsl @@ -0,0 +1,9 @@ +in vec2 v_position; +in vec2 v_texture; +out vec2 uv; + +void main() +{ + uv = v_texture; + gl_Position = vec4( v_position.xy, 0.0, 1.0 ); +} diff --git a/docs/Persistent b/docs/Persistent deleted file mode 100644 index e69de29..0000000 diff --git a/docs/Readme.md b/docs/Readme.md new file mode 100644 index 0000000..aa35150 --- /dev/null +++ b/docs/Readme.md @@ -0,0 +1,3 @@ +# Docs + +I haven't gotten around to this yet. After the codebase is bootstrapped I'll be jotting down all the info.. diff --git a/docs/ui.md b/docs/ui.md index 5ca2bec..d7bdc4e 100644 --- a/docs/ui.md +++ b/docs/ui.md @@ -1,2 +1,4 @@ # UI +TODO... + diff --git a/docs/ui_state.md b/docs/ui_state.md deleted file mode 100644 index bf3c8de..0000000 --- a/docs/ui_state.md +++ /dev/null @@ -1,39 +0,0 @@ -# UI - -## Ideal UI_Box processing per-frame - -Would be done in this order: - -Build Graph Start - -0. Parent constructed -1. `ui_box_make()` -2. Prepare layout & style -3. Construct & process children -4. Post-children populated processing -5. Auto-layout box -6. Process signal from children & depdendent events -7. `ui_signal_from_box(box)` -8. Process state dependent on signal -9. ... Eventual Render Pass - -Issues: - -You want to batch auto-layout to be deferred to the end of the construction for the state graph of the frame. -Rendering should be handled outside of the update tick asynchronously (at worst case). -StyleCombo and LayoutCombos are not stored in UI_Box (it would b N * (Style + Layout) per box of memory where N is the number of entries in a combo (right now there is 4) ) -A layout must be choosen before auto-layout occurs and rn the convention is that layout & style are choosen at the end of a signal since it depends on the box's state from the signal. - -Adjusted order: - -0. Parent constructed -1. Prepare layout & style beforehand -2. `ui_box_make()` -3. `ui_signal_from_box(box)` -4. Construct & process children -5. Post-children populated processing -6. ... Build Graph End -7. Auto-Layout Pass -8. Eventual Render Pass - - diff --git a/scripts/compile_shaders.ps1 b/scripts/compile_shaders.ps1 index 455edaa..1946053 100644 --- a/scripts/compile_shaders.ps1 +++ b/scripts/compile_shaders.ps1 @@ -13,17 +13,27 @@ $path_shaders = join-path $path_sectr 'shaders' $sokol_shdc = join-path $path_sokol_tools 'bin/win32/sokol-shdc.exe' -$shadersrc_learngl_font_glyph = join-path $path_shaders 'font_glyph.shdc.glsl' -$shaderout_learngl_font_glyph = join-path $path_shaders 'font_glyph.odin' +$shadersrc_simple_font_glyph = join-path $path_shaders 'simple_font_glyph.shdc.glsl' +$shaderout_simple_font_glyph = join-path $path_shaders 'simple_font_glyph.odin' + +$shadersrc_ve_blit_atlas = join-path $path_shaders 've_blit_atlas.shdc.glsl' +$shaderout_ve_blit_atlas = join-path $path_shaders 've_blit_atlas.odin' + +$shadersrc_ve_draw_text = join-path $path_shaders 've_draw_text.shdc.glsl' +$shaderout_ve_draw_text = join-path $path_shaders 've_draw_text.odin' + +$shadersrc_ve_render_glyph = join-path $path_shaders 've_render_glyph.shdc.glsl' +$shaderout_ve_render_glyph = join-path $path_shaders 've_render_glyph.odin' $flag_input = '--input ' $flag_output = '--output ' $flag_target_lang = '--slang ' $flag_format_odin = '--format=sokol_odin' +$flag_module = '--module' -$cmd_args = @() -$cmd_args += $flag_input + $shadersrc_learngl_font_glyph -$cmd_args += $flag_output + $shaderout_learngl_font_glyph -$cmd_args += $flag_target_lang + 'hlsl5' - -& $sokol_shdc --input $shadersrc_learngl_font_glyph --output $shaderout_learngl_font_glyph --slang 'hlsl5' $flag_format_odin +push-location $path_shaders +& $sokol_shdc --input $shadersrc_simple_font_glyph --output $shaderout_simple_font_glyph --slang 'hlsl5' $flag_format_odin +& $sokol_shdc --input $shadersrc_ve_blit_atlas --output $shaderout_ve_blit_atlas --slang 'hlsl5' $flag_format_odin $flag_module='vefc_blit_atlas' +& $sokol_shdc --input $shadersrc_ve_render_glyph --output $shaderout_ve_render_glyph --slang 'hlsl5' $flag_format_odin $flag_module='vefc_render_glyph' +& $sokol_shdc --input $shadersrc_ve_draw_text --output $shaderout_ve_draw_text --slang 'hlsl5' $flag_format_odin $flag_module='vefc_draw_text' +pop-location