Commit graph

321 commits

Author SHA1 Message Date
Gered 07b093ee39 initial stab at a simd version of per_pixel_triangle_2d
the results are highly disappointing. i am almost certainly going to
seriously revisit scanline-based triangle rasterization as a result of
this.

first off, there's some annoying floating point inaccuracy differences
introduced with this change that is throwing some things off slightly
(most noticeable in texture sampling). i noticed this manually comparing
barycentric coordinates for a small triangle both with and without
simd. i noticed that there were small discrepancies. i assume this is
the cause, but i am at a loss how this has crept in and how it is so
noticeable despite the fact that the differences are very small. ugh.

second, the performance improvement is .... negligible. seriously
negligible. ONLY the most simple triangle rendering sees some small
gains (like solid color, no per-pixel interpolation). to be honest,
i kind of expected that i would see no gains in the more advanced
triangle rendering (like multicolor+blended, textured+blended and also
textured+multicolor+blended) because in those cases the per-pixel
operations really seem to dwarf the cost of all of the pixel/coordinate
stepping that is happening outside the pixel_fn code. the "fix" here
is likely to either use avx / avx512 simd and try to write some
pixel_fn code that can calculate multiple pixels simultaneously. this is
complicated though because there's yet unanswered questions about how
this could be worked in to the existing pixel_fn "architecture" and how
to handle cases where only some of the 4 pixels in each step are
to be rendered. maybe easy enough, but i suspect this ends up adding
more comparisons and branches in the inner loop ... which may just
continue to kill any possible performance gains. the other option is
to use threads somehow, although if threads are on the table, i'd
rather just do parallel row rendering ... that would seem to be
significantly simpler and more efficient?

however, i do not want to require avx / avx512 support right now.
probably avx wouldn't be unreasonable, but i don't believe avx512 is
ubiquitous enough yet. i'd ideally want any code i write to be runnable
on any x86 machine in the past 10-15 years. this is also what makes
even avx questionable in my mind.

threading ... i am unsure of. frankly, half the point of this library
was to keep things simple in an "old school" kind of way, and threading
seems the opposite of that to me.

ugh ugh ugh. i fucking hate this.
2023-04-26 18:55:14 -04:00
Gered 3a27994091 add simd f32x4 nearly_equal helper function 2023-04-26 18:29:02 -04:00
Gered b4a9b82bf8 update triangle graphics ref tests with yet a few more variations 2023-04-22 21:08:07 -04:00
Gered dde2c314ae update triangle graphics reference tests with more variations
two primary goals with this change:

1. test triangle dimensions of varying widths, in preparation for
   upcoming simd per_pixel_triangle_2d changes. we want to ensure that
   scenarios where `width < 4` and `width % 4 != 0` continue to work
   fine after simd changes are done
2. test triangle rendering at various rotations, because i remember
   while testing fill rule changes, sometimes issues would only be
   visible at certain rotations. so this is mostly just useful for
   blended rendering methods, but still, is probably generally useful
   too ...
2023-04-21 18:20:08 -04:00
Gered 83b5e1eabe move updating graphics ref test images under conditional compilation 2023-04-21 16:19:15 -04:00
Gered 865801a62b add comment explaining reason for nightly use 2023-04-21 14:58:14 -04:00
Gered 9cea60ebc4 specify nightly toolchain by date
i did not expect this to be problematic so soon, based on what i'd
read in various places about the stability of nightly (especially so
for the most common platforms like x86_64, etc)

as i write this commit message, all nightly versions past this date
fail to build ggdt, failing with an "illegal instruction" error.

sigh. this makes me question whether trying to use simd right now is
actually worth it ...
2023-04-20 23:00:51 -04:00
Gered 11d9225e5e refactor triangle rendering logic a bit 2023-04-20 17:46:49 -04:00
Gered ba4792575e convert RgbaBitmap triangle rendering pixel functions to use simd
some noticeable performance gains from this, mostly just for the
blended triangle rendering variants
2023-04-19 21:52:08 -04:00
Gered da4345e3e5 add simd color types and color function variants 2023-04-19 21:47:29 -04:00
Gered c289bbdd71 refactor remaining BlendFunction operations into standalone functions 2023-04-19 21:46:05 -04:00
Gered 174fe3a93d switch to nightly and enable portable_simd feature
i really did not want to use nightly, but i think it is worth it for
portable_simd which is still nightly-only (and i'm guessing will be
for a long while still). i was not particularly enthusiastic about any
of the alternative libraries that exist for stable rust simd, as it
always seemed like something small was missing from what i knew i would
want longer term.
2023-04-19 17:31:48 -04:00
Gered f6283a2634 add BlendFunction blend method variant for unpacked colors
also renamed the existing method to be more explicit
2023-04-19 15:44:37 -04:00
Gered 02349d09a2 add color type alias. add color fn variants using 4 color components
the color type aliases have been a long time coming. it might make
sense to re-work the various color functions into some traits that
these color type aliases implement.

added the color function variants that accept and/or return 4 color
component arrays to aide in code that is doing more complex color
manipulation where it just makes more sense to always be working with
4 color component arrays instead of always converting to/from packed
and unpacked formats
2023-04-19 15:40:07 -04:00
Gered 755d13eef9 update color functions to work with arrays instead of bare components 2023-04-18 16:42:13 -04:00
Gered 88bea61bab "fix" some compiler warnings
while these are not used currently, i'm not able to rule out the
possiblity that i'll want to use them in the near-ish future for future
tests.
2023-04-17 15:27:17 -04:00
Gered ef45992130 bump up version of bitflags 2023-04-17 15:26:15 -04:00
Gered 73e5b9c7bc tweak all internal pub mod / pub use and re-do the prelude module
this is based off what i saw some other libraries doing. i'm not sure
what is the "best practice" to be honest, but i definitely like this.
especially the prelude is now much simpler, which is nice.
2023-04-17 15:25:55 -04:00
Gered e8847d01be missed removal of one sub-prelude module. oops 2023-04-17 14:54:24 -04:00
Gered 78dd97cb12 all of these "tests" modules don't actually need to be public 2023-04-16 20:39:57 -04:00
Gered c6549e37a9 put all the prelude stuff into a single prelude module
i still don't like this
2023-04-16 20:39:10 -04:00
Gered f64bba30d2 update screenshot 2023-04-15 02:19:38 -04:00
Gered e9ea08c882 add "push" button to imgui_integration 2023-04-15 02:17:02 -04:00
Gered 0cae9d0367 fix move entity button not working for all entities 2023-04-15 02:09:15 -04:00
Gered cb3a2673f9 add ability to move entities to imgui_integration example 2023-04-14 19:22:16 -04:00
Gered dc6b96d545 remove variable_screen_size example. imgui_integration does this too 2023-04-14 14:07:04 -04:00
Gered 49301a0be9 add readme for imgui_integration example 2023-04-14 14:00:02 -04:00
Gered 21259bfb10 show an imgui window with entity info, etc 2023-04-14 13:59:38 -04:00
Gered 1d64384088 update imgui helpers, split mouse_over_any into two separate functions
since it was kind of doing both, but the name implied otherwise, and
hence was incorrect behaviour
2023-04-14 13:58:41 -04:00
Gered b9ae66ea44 Merge branch 'master' into imgui 2023-04-14 13:19:04 -04:00
Gered fbf6d1e716 added "manual" integration tests for basic system/window verification
since i cannot think of any way to verify these tests in a automated
way, these are all set up currently as "ignored" tests which need to be
manually run (either directly via the IDE, e.g. CLion as I use, or via
the an ALTERNATIVE test runner via the CLI (such as nextest). these
cannot be run all together via `cargo test` (even if running with only
a single thread). `cargo test` can only be used to run them successfully
one test per invocation.
2023-04-14 13:18:47 -04:00
Gered 9a421f32a6 add #[inline] attributes to all the GeneralBitmap 1-line methods 2023-04-14 12:21:34 -04:00
Gered babb70cf30 add more useful methods to GeneralBitmap trait and impls 2023-04-14 12:19:28 -04:00
Gered e0a4ea9c5b increase MAX_KEYS constant to match underlying SDL key scancode max
SDL_NUM_SCANCODES is defined as 512 currently
2023-04-13 14:44:36 -04:00
Gered 43c921680b add num_derive's FromPrimitive derive to keyboard and mouse button enums
this has very limited use, outside of some tests i am writing right now,
but maybe it will be useful down the road.

(i suppose mostly, i just wanted to try this out for myself ...)
2023-04-13 14:43:13 -04:00
Gered 8e02fdd657 map our KeyModifiers bitflags struct to the original SDL values
rather then copy+pasting the constants. i doubt they'll change, but
you never know i guess ...
2023-04-12 15:20:24 -04:00
Gered db60579db4 fix mouse button event mapping
this was preventing applications from picking up basically all non-left
button states
2023-04-12 15:19:39 -04:00
Gered 7cff580bcb helper trait for imgui helper functions
only one for now. i am assuming i will want more in the future.
2023-04-11 22:12:55 -04:00
Gered 424c63d414 imgui_integration example initial commit, work in progress
mostly working, but the imgui ui part is only a placeholder.

also this example project is kind of overly complicated, but i really
wanted this to be something that somewhat resembles a real tool that
i'd want to build.
2023-04-10 19:40:46 -04:00
Gered 4069a92843 add generic pixel type parameter to SystemResources
this has no immediate use, but i think it will be useful in the future
for writing generic constraints requiring 32-bit color support while
not forcing use of any specific SystemResources implementation
2023-04-09 20:33:44 -04:00
Gered d85293d9bf remove need to pass a system struct to prepare a new imgui frame
just needed the destination bitmap dimensions and we don't need the
whole system struct for that
2023-04-08 21:04:45 -04:00
Gered 0f4ed2965c add wrapper struct to simplify imgui init and usage
rather than forcing use of 3 separate structs
2023-04-08 20:52:38 -04:00
Gered 3befd786ca adjust default imgui style's rounding settings 2023-04-07 14:46:17 -04:00
Gered eeee7ed67b cleanup 2023-04-07 14:31:50 -04:00
Gered 89be7f5e89 minor simplifications
sort of
2023-04-07 14:30:22 -04:00
Gered e3d585ec90 initial commit of ggdt_imgui library
fairly basic at this stage, but working
2023-04-07 14:21:27 -04:00
Gered cf6b7e5e3c minor crate import cleanups 2023-04-06 21:50:34 -04:00
Gered df31483cbd set opt-level = 1 on the dev profile by default 2023-04-06 21:15:17 -04:00
Gered 231ba10f1e remove Copy trait from these event enums to be consistent with the rest
since the TextInput event cannot implement Copy, necessitating the
removal of the Copy trait from KeyboardEvent, it feels wrong to me to
have the other event enums implement Copy, because it is inconsistent.

so while this is less convenient potentially, it feels consistent.

probably not a big deal in the future one way or the other.
2023-04-05 12:45:09 -04:00
Gered 1c39832801 add keyboard TextInput event mapping 2023-04-05 12:42:57 -04:00