Commit Graph

2324 Commits

Author SHA1 Message Date
Simon Anciaux d926166630 Changed the fix a little to test only 4 vertex per characters (instead of 6).
Removed the "draw = true;" left from testing.
2025-07-07 13:05:18 -07:00
Simon Anciaux 52124edcd8 Avoid rendering rectangles (and characters) that are outside the window bounds.
While debugging an issue with the dx11 backend, I noticed that 4coder only clipped rectangles that are outside the screen vertically. Another potential issue (it might be the intended behavior) causes some things to not work with line wrapping, which means that we could have very long horizontal lines, causing a lot of vertices being sent through the render pipeline that will just be clipped after the vertex shader. This causes higher than necessary GPU memory usage, and low performance for things that aren't rendered in the end.

An example of problematic is:
```c
u8 data[ ] = {0,0,0,0,...,0}; // With a lot of zero, and no space between them.
```

This fix just checks that at least one vertex of each rectangle we try to draw is in the screen. It would be better to use the current clip rect, but it's not available at that point in the pipeline. If we want we can modify the API a little to pass it down, as a parameter to those functions.

Using RenderDoc, I saw the vertex count going from over 500K to 13K with this change, and the performance were from 57ms to 25ms. So perfs are not great (but still an improvement), but testing the bounds of 500K vertices is not free. Fixing the line wrapping issue would probably help getting back to reasonable frame rate.
2025-07-07 13:05:06 -07:00
Simon Anciaux dadb7dc49a Fixed crashing when 4coder tries to render more vertex than the vertex buffer reserved. We create a new buffer to accommodate the required size, and if that fails, we skip rendering the current vertex group. 2025-07-07 13:04:14 -07:00
Simon Anciaux 84da2da350 Changed `true` to `GL_TRUE` for `WGL_DOUBLE_BUFFER_ARB` to use OpenGL wording. 2025-07-07 13:03:52 -07:00
Simon Anciaux cbbd83affc Commented the DirectX 11 define to default to OpenGL. 2025-07-07 13:03:44 -07:00
Simon Anciaux c81d9b4e97 Renamed files from direcx to dx11. 2025-07-07 13:03:34 -07:00
Simon Anciaux d0a18fcdb7 Renamed "directx" to dx11 in several variable names, types and defines.
Added date to NOTEs and TODOs.
Tried to make log strings more useful, even if I don't know how you display things log with log_os.
2025-07-07 13:03:26 -07:00
Simon Anciaux 7ce0a7d698 code/platform_win32/4ed_directx_render.cpp: Reuse freed textures. Rename variables so that texture handle are always named texid. 2025-07-07 13:03:19 -07:00
Simon Anciaux b651847ba3 4ed_directx_render.cpp: Initialize textures to zero to avoid having random pixel values that changes the result of linear sampling on the edge of characters. 2025-07-07 13:03:10 -07:00
Simon Anciaux e4b4e5c943 code/platform_win32/4ed_directx_render.cpp: Fixed the way texture array are updated. Note that the font provider rectangle packer contains a bug, and it will never produce several texture slice, it will only grow the texture on y to accommodate for more characters.
code/platform_win32/win32_opengl.cpp: Enabled double buffering to fix graphical glitches on AMD cards.
2025-07-07 13:02:52 -07:00
Simon Anciaux 911df4ce05 code/bin/4ed_build.cpp: Removed OpenGL.lib. It's added with #pragma comment in win32_opengl.cpp so that we don't need to do special things to keep OpenGL and DirectX both working.
code/platform_win32/win32_4ed.cpp:
- Modification to be able to choose between OpenGL and DirectX. You choose between the two by defining WIN32_DIRECTX macro. If you don't define it it uses OpenGL.
- Note that win32_gl_create_window and other part of the file that depend on OpenGL or DirectX have been moved to win32_opengl.cpp and win32_directx.cpp.
- Fixed os_popup_error using the title as the message and the message as the title.

code/platform_win32/win32_opengl.cpp: Contains previous code that was in win32_4ed.cpp.

code/platform_win32/win32_directx.cpp: Code for creating a DirectX window and context.

code/platform_win32/4ed_directx_render.cpp: Imlementation of the 4coder renderer using DirectX.
2025-07-07 13:02:42 -07:00
Simon Anciaux f2abe27704 4ed_font_provider_freetype.cpp: Rewrote the ft__bad_rect_pack_next function. There were several issues with the previous function that didn't manifest because the default size for the font atlas is 1024 * 1024 and the default 4coder only use about 1/8 of it.
To see the issues, you can set the font atlas size to 128 * 128 by changing line 325 "ft__bad_rect_pack_init(&pack, V2i32(1024, 1024));" to "ft__bad_rect_pack_init(&pack, V2i32(128, 128));".

The first issue was that the max_dim.y parameter was not respected. The dimension produced would always grow on Y to accommodate for more characters. And so the whole texture array thing was never use.

A second issue was that when a character didn't fit on the x axis, we created a new line, but never check that the new line fitted in the current texture slice.

A third issue was that when we ended a line because a character didn't fit vertically, we grew the line with a line height equal to the height of the character that didn't fit.
2025-07-07 12:59:37 -07:00
Peter Slattery 7359649465 Restructure default_render_buffer to only color visible tokens, and only look up tokens that are identifiers 2025-07-07 12:33:29 -07:00
Peter Slattery 2ab0c0a2de Increase Code_Index name_hash size 2025-07-07 12:32:45 -07:00
Peter Slattery 6ae690691c Cleaning up build-config.sh 2025-07-07 09:37:12 -07:00
Peter Slattery 75e72875ff Implement new build system 2025-07-06 12:44:54 -07:00
Peter Slattery 69556235d5 Squashing macro-redefined error in clang 2025-07-06 12:37:41 -07:00
Peter Slattery bbf8a2566d Adding build_new/temp to the gitignore 2025-07-06 11:35:55 -07:00
Peter Slattery 0866aedcc9 Phase 1: Basic config and toolchain detection 2025-07-05 13:35:22 -07:00
Peter Slattery 5f35da8cb7 Planning build system simplification 2025-07-05 13:01:30 -07:00
Peter Slattery 0d6a5e4e06 Bindings for replace identifier and replace selection 2025-04-30 12:38:07 -07:00
Peter Slattery 91cc66a52a Fixing no keyup events while command is pressed on mac 2025-04-24 16:45:45 -07:00
Peter Slattery b280722b1c set NSApp activateIgnoringOtherApps to YES 2025-04-24 16:18:01 -07:00
PS be632574e6 Added yeet sheet implementation 2024-05-13 19:29:16 -07:00
PS 46a0466ff4 Removed File_Edit_Positions.last_set_type since it was always set but never read 2024-05-13 17:42:38 -07:00
PS 24f7f66a24 Added scope highlight colors 2024-05-13 17:24:33 -07:00
PS 001cf5fa57 Buffer name resolution simply appends a project relative path for files inside the project and a global path for files outside. 2024-05-13 17:10:09 -07:00
Peter Slattery 2142ef2ce9 Cleaning up line endings on save 2024-04-27 13:43:54 -07:00
PS 120c6ceaad gs_parse_jump_location handles jai paths better 2024-03-27 13:49:52 -07:00
PS 5842d13294 string_find_first_of_set impl 2024-03-27 13:49:29 -07:00
PS 2c82233524 Adding freetype.lib for x64 windows dependencies 2024-03-27 13:49:16 -07:00
Peter Slattery 3f1c591196 Reverting prior change to map_loose_match 2024-03-26 16:00:50 -07:00
Peter Slattery f1d6ac0e53 adding execute permissions to build-mac-dev.sh 2024-03-22 18:16:17 -06:00
Peter Slattery e33bdffc7d Fixing issue where keyUp events aren't sent for keys that become modified by the command key 2024-03-22 17:55:59 -06:00
Peter Slattery cba2574e8a 4coder_command_map now gets the best match for a given input rather than the first match when Loose Matching 2024-03-22 16:17:44 -06:00
Peter Slattery 58a4314177 ship-files/config sets user to PS 2024-03-22 16:17:03 -06:00
Peter Slattery 8675d371a4 dedicated build-mac-release and build-mac-dev files in bin 2024-03-22 16:16:48 -06:00
Peter Slattery 41d0d07b5c libfreetype updates 2024-03-22 16:16:31 -06:00
Peter Slattery 7f2a414182 package-mac.sh grants execute permissions to the output executable 2024-03-22 16:15:38 -06:00
Peter Slattery ad189e911a Adding mm files to treat-as-code 2024-02-14 18:11:12 -08:00
PS 24c8370f75 Indent next line only on hitting enter 2024-02-10 20:12:36 -08:00
PS 5aebe18778 Disabling undo fade out 2024-02-10 20:12:20 -08:00
PS 18e608a152 Parsing jai style compiler errors 2024-02-10 19:34:25 -08:00
PS ca075e7392 default_font_hinting is true by default 2024-02-10 18:52:45 -08:00
PS 22fa2794e7 Project generation uses treat_as_code extensions to create project include patterns 2024-02-10 18:45:05 -08:00
PS e3ba01570a Backspace in file search deletes whole word 2024-02-10 15:55:05 -08:00
PS 8552305ecc Modal cursor recoloring 2024-02-10 15:43:16 -08:00
PS 7aa033783c Implemented custom modal bindings 2024-02-10 15:38:37 -08:00
PS 0a03ea05f1 Adding dirty file reloading 2024-02-10 14:25:22 -08:00
PS 80b780278a Removed custom/audio 2024-02-10 14:25:13 -08:00