···11+MIT License
22+33+Copyright (c) 2026 azom.dev
44+55+Permission is hereby granted, free of charge, to any person obtaining a copy
66+of this software and associated documentation files (the "Software"), to deal
77+in the Software without restriction, including without limitation the rights
88+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
99+copies of the Software, and to permit persons to whom the Software is
1010+furnished to do so, subject to the following conditions:
1111+1212+The above copyright notice and this permission notice shall be included in all
1313+copies or substantial portions of the Software.
1414+1515+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1616+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1717+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121+SOFTWARE.
+360
LICENSE-SHADER
···11+Creative Commons Legal Code
22+33+Attribution-NonCommercial-ShareAlike 3.0 Unported
44+55+ CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
66+ LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN
77+ ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
88+ INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
99+ REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR
1010+ DAMAGES RESULTING FROM ITS USE.
1111+1212+License
1313+1414+THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE
1515+COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY
1616+COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS
1717+AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
1818+1919+BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE
2020+TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY
2121+BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS
2222+CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND
2323+CONDITIONS.
2424+2525+1. Definitions
2626+2727+ a. "Adaptation" means a work based upon the Work, or upon the Work and
2828+ other pre-existing works, such as a translation, adaptation,
2929+ derivative work, arrangement of music or other alterations of a
3030+ literary or artistic work, or phonogram or performance and includes
3131+ cinematographic adaptations or any other form in which the Work may be
3232+ recast, transformed, or adapted including in any form recognizably
3333+ derived from the original, except that a work that constitutes a
3434+ Collection will not be considered an Adaptation for the purpose of
3535+ this License. For the avoidance of doubt, where the Work is a musical
3636+ work, performance or phonogram, the synchronization of the Work in
3737+ timed-relation with a moving image ("synching") will be considered an
3838+ Adaptation for the purpose of this License.
3939+ b. "Collection" means a collection of literary or artistic works, such as
4040+ encyclopedias and anthologies, or performances, phonograms or
4141+ broadcasts, or other works or subject matter other than works listed
4242+ in Section 1(g) below, which, by reason of the selection and
4343+ arrangement of their contents, constitute intellectual creations, in
4444+ which the Work is included in its entirety in unmodified form along
4545+ with one or more other contributions, each constituting separate and
4646+ independent works in themselves, which together are assembled into a
4747+ collective whole. A work that constitutes a Collection will not be
4848+ considered an Adaptation (as defined above) for the purposes of this
4949+ License.
5050+ c. "Distribute" means to make available to the public the original and
5151+ copies of the Work or Adaptation, as appropriate, through sale or
5252+ other transfer of ownership.
5353+ d. "License Elements" means the following high-level license attributes
5454+ as selected by Licensor and indicated in the title of this License:
5555+ Attribution, Noncommercial, ShareAlike.
5656+ e. "Licensor" means the individual, individuals, entity or entities that
5757+ offer(s) the Work under the terms of this License.
5858+ f. "Original Author" means, in the case of a literary or artistic work,
5959+ the individual, individuals, entity or entities who created the Work
6060+ or if no individual or entity can be identified, the publisher; and in
6161+ addition (i) in the case of a performance the actors, singers,
6262+ musicians, dancers, and other persons who act, sing, deliver, declaim,
6363+ play in, interpret or otherwise perform literary or artistic works or
6464+ expressions of folklore; (ii) in the case of a phonogram the producer
6565+ being the person or legal entity who first fixes the sounds of a
6666+ performance or other sounds; and, (iii) in the case of broadcasts, the
6767+ organization that transmits the broadcast.
6868+ g. "Work" means the literary and/or artistic work offered under the terms
6969+ of this License including without limitation any production in the
7070+ literary, scientific and artistic domain, whatever may be the mode or
7171+ form of its expression including digital form, such as a book,
7272+ pamphlet and other writing; a lecture, address, sermon or other work
7373+ of the same nature; a dramatic or dramatico-musical work; a
7474+ choreographic work or entertainment in dumb show; a musical
7575+ composition with or without words; a cinematographic work to which are
7676+ assimilated works expressed by a process analogous to cinematography;
7777+ a work of drawing, painting, architecture, sculpture, engraving or
7878+ lithography; a photographic work to which are assimilated works
7979+ expressed by a process analogous to photography; a work of applied
8080+ art; an illustration, map, plan, sketch or three-dimensional work
8181+ relative to geography, topography, architecture or science; a
8282+ performance; a broadcast; a phonogram; a compilation of data to the
8383+ extent it is protected as a copyrightable work; or a work performed by
8484+ a variety or circus performer to the extent it is not otherwise
8585+ considered a literary or artistic work.
8686+ h. "You" means an individual or entity exercising rights under this
8787+ License who has not previously violated the terms of this License with
8888+ respect to the Work, or who has received express permission from the
8989+ Licensor to exercise rights under this License despite a previous
9090+ violation.
9191+ i. "Publicly Perform" means to perform public recitations of the Work and
9292+ to communicate to the public those public recitations, by any means or
9393+ process, including by wire or wireless means or public digital
9494+ performances; to make available to the public Works in such a way that
9595+ members of the public may access these Works from a place and at a
9696+ place individually chosen by them; to perform the Work to the public
9797+ by any means or process and the communication to the public of the
9898+ performances of the Work, including by public digital performance; to
9999+ broadcast and rebroadcast the Work by any means including signs,
100100+ sounds or images.
101101+ j. "Reproduce" means to make copies of the Work by any means including
102102+ without limitation by sound or visual recordings and the right of
103103+ fixation and reproducing fixations of the Work, including storage of a
104104+ protected performance or phonogram in digital form or other electronic
105105+ medium.
106106+107107+2. Fair Dealing Rights. Nothing in this License is intended to reduce,
108108+limit, or restrict any uses free from copyright or rights arising from
109109+limitations or exceptions that are provided for in connection with the
110110+copyright protection under copyright law or other applicable laws.
111111+112112+3. License Grant. Subject to the terms and conditions of this License,
113113+Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
114114+perpetual (for the duration of the applicable copyright) license to
115115+exercise the rights in the Work as stated below:
116116+117117+ a. to Reproduce the Work, to incorporate the Work into one or more
118118+ Collections, and to Reproduce the Work as incorporated in the
119119+ Collections;
120120+ b. to create and Reproduce Adaptations provided that any such Adaptation,
121121+ including any translation in any medium, takes reasonable steps to
122122+ clearly label, demarcate or otherwise identify that changes were made
123123+ to the original Work. For example, a translation could be marked "The
124124+ original work was translated from English to Spanish," or a
125125+ modification could indicate "The original work has been modified.";
126126+ c. to Distribute and Publicly Perform the Work including as incorporated
127127+ in Collections; and,
128128+ d. to Distribute and Publicly Perform Adaptations.
129129+130130+The above rights may be exercised in all media and formats whether now
131131+known or hereafter devised. The above rights include the right to make
132132+such modifications as are technically necessary to exercise the rights in
133133+other media and formats. Subject to Section 8(f), all rights not expressly
134134+granted by Licensor are hereby reserved, including but not limited to the
135135+rights described in Section 4(e).
136136+137137+4. Restrictions. The license granted in Section 3 above is expressly made
138138+subject to and limited by the following restrictions:
139139+140140+ a. You may Distribute or Publicly Perform the Work only under the terms
141141+ of this License. You must include a copy of, or the Uniform Resource
142142+ Identifier (URI) for, this License with every copy of the Work You
143143+ Distribute or Publicly Perform. You may not offer or impose any terms
144144+ on the Work that restrict the terms of this License or the ability of
145145+ the recipient of the Work to exercise the rights granted to that
146146+ recipient under the terms of the License. You may not sublicense the
147147+ Work. You must keep intact all notices that refer to this License and
148148+ to the disclaimer of warranties with every copy of the Work You
149149+ Distribute or Publicly Perform. When You Distribute or Publicly
150150+ Perform the Work, You may not impose any effective technological
151151+ measures on the Work that restrict the ability of a recipient of the
152152+ Work from You to exercise the rights granted to that recipient under
153153+ the terms of the License. This Section 4(a) applies to the Work as
154154+ incorporated in a Collection, but this does not require the Collection
155155+ apart from the Work itself to be made subject to the terms of this
156156+ License. If You create a Collection, upon notice from any Licensor You
157157+ must, to the extent practicable, remove from the Collection any credit
158158+ as required by Section 4(d), as requested. If You create an
159159+ Adaptation, upon notice from any Licensor You must, to the extent
160160+ practicable, remove from the Adaptation any credit as required by
161161+ Section 4(d), as requested.
162162+ b. You may Distribute or Publicly Perform an Adaptation only under: (i)
163163+ the terms of this License; (ii) a later version of this License with
164164+ the same License Elements as this License; (iii) a Creative Commons
165165+ jurisdiction license (either this or a later license version) that
166166+ contains the same License Elements as this License (e.g.,
167167+ Attribution-NonCommercial-ShareAlike 3.0 US) ("Applicable License").
168168+ You must include a copy of, or the URI, for Applicable License with
169169+ every copy of each Adaptation You Distribute or Publicly Perform. You
170170+ may not offer or impose any terms on the Adaptation that restrict the
171171+ terms of the Applicable License or the ability of the recipient of the
172172+ Adaptation to exercise the rights granted to that recipient under the
173173+ terms of the Applicable License. You must keep intact all notices that
174174+ refer to the Applicable License and to the disclaimer of warranties
175175+ with every copy of the Work as included in the Adaptation You
176176+ Distribute or Publicly Perform. When You Distribute or Publicly
177177+ Perform the Adaptation, You may not impose any effective technological
178178+ measures on the Adaptation that restrict the ability of a recipient of
179179+ the Adaptation from You to exercise the rights granted to that
180180+ recipient under the terms of the Applicable License. This Section 4(b)
181181+ applies to the Adaptation as incorporated in a Collection, but this
182182+ does not require the Collection apart from the Adaptation itself to be
183183+ made subject to the terms of the Applicable License.
184184+ c. You may not exercise any of the rights granted to You in Section 3
185185+ above in any manner that is primarily intended for or directed toward
186186+ commercial advantage or private monetary compensation. The exchange of
187187+ the Work for other copyrighted works by means of digital file-sharing
188188+ or otherwise shall not be considered to be intended for or directed
189189+ toward commercial advantage or private monetary compensation, provided
190190+ there is no payment of any monetary compensation in con-nection with
191191+ the exchange of copyrighted works.
192192+ d. If You Distribute, or Publicly Perform the Work or any Adaptations or
193193+ Collections, You must, unless a request has been made pursuant to
194194+ Section 4(a), keep intact all copyright notices for the Work and
195195+ provide, reasonable to the medium or means You are utilizing: (i) the
196196+ name of the Original Author (or pseudonym, if applicable) if supplied,
197197+ and/or if the Original Author and/or Licensor designate another party
198198+ or parties (e.g., a sponsor institute, publishing entity, journal) for
199199+ attribution ("Attribution Parties") in Licensor's copyright notice,
200200+ terms of service or by other reasonable means, the name of such party
201201+ or parties; (ii) the title of the Work if supplied; (iii) to the
202202+ extent reasonably practicable, the URI, if any, that Licensor
203203+ specifies to be associated with the Work, unless such URI does not
204204+ refer to the copyright notice or licensing information for the Work;
205205+ and, (iv) consistent with Section 3(b), in the case of an Adaptation,
206206+ a credit identifying the use of the Work in the Adaptation (e.g.,
207207+ "French translation of the Work by Original Author," or "Screenplay
208208+ based on original Work by Original Author"). The credit required by
209209+ this Section 4(d) may be implemented in any reasonable manner;
210210+ provided, however, that in the case of a Adaptation or Collection, at
211211+ a minimum such credit will appear, if a credit for all contributing
212212+ authors of the Adaptation or Collection appears, then as part of these
213213+ credits and in a manner at least as prominent as the credits for the
214214+ other contributing authors. For the avoidance of doubt, You may only
215215+ use the credit required by this Section for the purpose of attribution
216216+ in the manner set out above and, by exercising Your rights under this
217217+ License, You may not implicitly or explicitly assert or imply any
218218+ connection with, sponsorship or endorsement by the Original Author,
219219+ Licensor and/or Attribution Parties, as appropriate, of You or Your
220220+ use of the Work, without the separate, express prior written
221221+ permission of the Original Author, Licensor and/or Attribution
222222+ Parties.
223223+ e. For the avoidance of doubt:
224224+225225+ i. Non-waivable Compulsory License Schemes. In those jurisdictions in
226226+ which the right to collect royalties through any statutory or
227227+ compulsory licensing scheme cannot be waived, the Licensor
228228+ reserves the exclusive right to collect such royalties for any
229229+ exercise by You of the rights granted under this License;
230230+ ii. Waivable Compulsory License Schemes. In those jurisdictions in
231231+ which the right to collect royalties through any statutory or
232232+ compulsory licensing scheme can be waived, the Licensor reserves
233233+ the exclusive right to collect such royalties for any exercise by
234234+ You of the rights granted under this License if Your exercise of
235235+ such rights is for a purpose or use which is otherwise than
236236+ noncommercial as permitted under Section 4(c) and otherwise waives
237237+ the right to collect royalties through any statutory or compulsory
238238+ licensing scheme; and,
239239+ iii. Voluntary License Schemes. The Licensor reserves the right to
240240+ collect royalties, whether individually or, in the event that the
241241+ Licensor is a member of a collecting society that administers
242242+ voluntary licensing schemes, via that society, from any exercise
243243+ by You of the rights granted under this License that is for a
244244+ purpose or use which is otherwise than noncommercial as permitted
245245+ under Section 4(c).
246246+ f. Except as otherwise agreed in writing by the Licensor or as may be
247247+ otherwise permitted by applicable law, if You Reproduce, Distribute or
248248+ Publicly Perform the Work either by itself or as part of any
249249+ Adaptations or Collections, You must not distort, mutilate, modify or
250250+ take other derogatory action in relation to the Work which would be
251251+ prejudicial to the Original Author's honor or reputation. Licensor
252252+ agrees that in those jurisdictions (e.g. Japan), in which any exercise
253253+ of the right granted in Section 3(b) of this License (the right to
254254+ make Adaptations) would be deemed to be a distortion, mutilation,
255255+ modification or other derogatory action prejudicial to the Original
256256+ Author's honor and reputation, the Licensor will waive or not assert,
257257+ as appropriate, this Section, to the fullest extent permitted by the
258258+ applicable national law, to enable You to reasonably exercise Your
259259+ right under Section 3(b) of this License (right to make Adaptations)
260260+ but not otherwise.
261261+262262+5. Representations, Warranties and Disclaimer
263263+264264+UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING AND TO THE
265265+FULLEST EXTENT PERMITTED BY APPLICABLE LAW, LICENSOR OFFERS THE WORK AS-IS
266266+AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE
267267+WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT
268268+LIMITATION, WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
269269+PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS,
270270+ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT
271271+DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED
272272+WARRANTIES, SO THIS EXCLUSION MAY NOT APPLY TO YOU.
273273+274274+6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE
275275+LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR
276276+ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES
277277+ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS
278278+BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
279279+280280+7. Termination
281281+282282+ a. This License and the rights granted hereunder will terminate
283283+ automatically upon any breach by You of the terms of this License.
284284+ Individuals or entities who have received Adaptations or Collections
285285+ from You under this License, however, will not have their licenses
286286+ terminated provided such individuals or entities remain in full
287287+ compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will
288288+ survive any termination of this License.
289289+ b. Subject to the above terms and conditions, the license granted here is
290290+ perpetual (for the duration of the applicable copyright in the Work).
291291+ Notwithstanding the above, Licensor reserves the right to release the
292292+ Work under different license terms or to stop distributing the Work at
293293+ any time; provided, however that any such election will not serve to
294294+ withdraw this License (or any other license that has been, or is
295295+ required to be, granted under the terms of this License), and this
296296+ License will continue in full force and effect unless terminated as
297297+ stated above.
298298+299299+8. Miscellaneous
300300+301301+ a. Each time You Distribute or Publicly Perform the Work or a Collection,
302302+ the Licensor offers to the recipient a license to the Work on the same
303303+ terms and conditions as the license granted to You under this License.
304304+ b. Each time You Distribute or Publicly Perform an Adaptation, Licensor
305305+ offers to the recipient a license to the original Work on the same
306306+ terms and conditions as the license granted to You under this License.
307307+ c. If any provision of this License is invalid or unenforceable under
308308+ applicable law, it shall not affect the validity or enforceability of
309309+ the remainder of the terms of this License, and without further action
310310+ by the parties to this agreement, such provision shall be reformed to
311311+ the minimum extent necessary to make such provision valid and
312312+ enforceable.
313313+ d. No term or provision of this License shall be deemed waived and no
314314+ breach consented to unless such waiver or consent shall be in writing
315315+ and signed by the party to be charged with such waiver or consent.
316316+ e. This License constitutes the entire agreement between the parties with
317317+ respect to the Work licensed here. There are no understandings,
318318+ agreements or representations with respect to the Work not specified
319319+ here. Licensor shall not be bound by any additional provisions that
320320+ may appear in any communication from You. This License may not be
321321+ modified without the mutual written agreement of the Licensor and You.
322322+ f. The rights granted under, and the subject matter referenced, in this
323323+ License were drafted utilizing the terminology of the Berne Convention
324324+ for the Protection of Literary and Artistic Works (as amended on
325325+ September 28, 1979), the Rome Convention of 1961, the WIPO Copyright
326326+ Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996
327327+ and the Universal Copyright Convention (as revised on July 24, 1971).
328328+ These rights and subject matter take effect in the relevant
329329+ jurisdiction in which the License terms are sought to be enforced
330330+ according to the corresponding provisions of the implementation of
331331+ those treaty provisions in the applicable national law. If the
332332+ standard suite of rights granted under applicable copyright law
333333+ includes additional rights not granted under this License, such
334334+ additional rights are deemed to be included in the License; this
335335+ License is not intended to restrict the license of any rights under
336336+ applicable law.
337337+338338+339339+Creative Commons Notice
340340+341341+ Creative Commons is not a party to this License, and makes no warranty
342342+ whatsoever in connection with the Work. Creative Commons will not be
343343+ liable to You or any party on any legal theory for any damages
344344+ whatsoever, including without limitation any general, special,
345345+ incidental or consequential damages arising in connection to this
346346+ license. Notwithstanding the foregoing two (2) sentences, if Creative
347347+ Commons has expressly identified itself as the Licensor hereunder, it
348348+ shall have all rights and obligations of Licensor.
349349+350350+ Except for the limited purpose of indicating to the public that the
351351+ Work is licensed under the CCPL, Creative Commons does not authorize
352352+ the use by either party of the trademark "Creative Commons" or any
353353+ related trademark or logo of Creative Commons without the prior
354354+ written consent of Creative Commons. Any permitted use will be in
355355+ compliance with Creative Commons' then-current trademark usage
356356+ guidelines, as may be published on its website or otherwise made
357357+ available upon request from time to time. For the avoidance of doubt,
358358+ this trademark restriction does not form part of this License.
359359+360360+ Creative Commons may be contacted at https://creativecommons.org/.
+46
README.md
···11+# heatslop
22+33+A dumb-but-fun space heater app that maxes out your CPU and GPU to warm up your room. It renders a procedural fire animation on the GPU while all your CPU cores brute-force search for prime numbers.
44+55+Yes, it is exactly as stupid as it sounds.
66+77+## What it does
88+99+- **GPU:** Runs a 3-pass fire shader (generation, gaussian blur, bloom composite) as fast as possible with vsync off. Your GPU will earn its electricity bill.
1010+- **CPU:** Every core runs trial division to find primes. The title bar shows how many primes have been found and how many primality tests are happening per second.
1111+- **Title bar:** Live FPS, core count, primes found, and tests/sec for primes.
1212+1313+## Screenshot
1414+1515+It's fire. On your screen. You get it.
1616+1717+## Building & Running
1818+1919+```
2020+cargo run --release
2121+```
2222+2323+Press `ESC` or close the window to stop.
2424+2525+`--release` matters. You want optimized prime crunching if you're going to waste electricity.
2626+2727+## The fire shader
2828+2929+The fire effect is from **ddsol**'s ["Bring the Heat"](https://www.shadertoy.com/view/4sfBWj) on Shadertoy. The original GLSL is preserved unmodified in `src/shaders/shadertoy/`. A Rust adapter module wraps it with wgpu preambles and applies two minimal workarounds for naga's GLSL parser limitations (precomputed matrix product, hardcoded array sizes). The original code is never touched.
3030+3131+Credit and thanks to [ddsol](https://www.shadertoy.com/user/ddsol) for the shader.
3232+3333+## The slop disclosure
3434+3535+This project was written almost entirely by an LLM. I designed the architecture (how the pieces connect, what the passes do, the module structure), but the vast majority of the code came out of wasting electricity. Hence the name.
3636+3737+**This is not representative of how I normally work.** My actual public-facing projects are not like this. When I use LLMs in real work, I read every single line, understand every single part, and treat the output as a starting point, not a finished product. This project exists because I wanted a space heater.
3838+3939+If you're wondering which LLM I used: I'm not saying. I don't do free advertising :p
4040+4141+## License
4242+4343+Dual licensed:
4444+4545+- **The Rust code** (everything except `src/shaders/shadertoy/`) is under the [MIT License](LICENSE-MIT).
4646+- **The fire shader** (`src/shaders/shadertoy/`) is by ddsol. I didn't find a specific license on the shader itself, but the [default license for Shadertoy shaders](https://www.shadertoy.com/terms) is [CC BY-NC-SA 3.0](LICENSE-SHADER).
+197
src/app.rs
···11+use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
22+use std::sync::Arc;
33+use std::time::Instant;
44+55+use winit::application::ApplicationHandler;
66+use winit::dpi::PhysicalSize;
77+use winit::event::WindowEvent;
88+use winit::event_loop::ActiveEventLoop;
99+use winit::window::{Window, WindowId};
1010+1111+use crate::cpu;
1212+use crate::gpu::GpuState;
1313+1414+pub struct App {
1515+ window: Option<Arc<Window>>,
1616+ gpu: Option<GpuState>,
1717+ running: Arc<AtomicBool>,
1818+ primes_found: Arc<AtomicU64>,
1919+ numbers_tested: Arc<AtomicU64>,
2020+ cpu_threads: Vec<std::thread::JoinHandle<()>>,
2121+ frame_count: u64,
2222+ last_fps_time: Instant,
2323+ fps: f64,
2424+ last_tested_count: u64,
2525+ tests_per_sec: f64,
2626+}
2727+2828+impl App {
2929+ pub fn new() -> Self {
3030+ Self {
3131+ window: None,
3232+ gpu: None,
3333+ running: Arc::new(AtomicBool::new(true)),
3434+ primes_found: Arc::new(AtomicU64::new(0)),
3535+ numbers_tested: Arc::new(AtomicU64::new(0)),
3636+ cpu_threads: Vec::new(),
3737+ frame_count: 0,
3838+ last_fps_time: Instant::now(),
3939+ fps: 0.0,
4040+ last_tested_count: 0,
4141+ tests_per_sec: 0.0,
4242+ }
4343+ }
4444+4545+ fn spawn_cpu_workers(&mut self) {
4646+ let num_threads = num_cpus::get();
4747+ log::info!("Spawning {} CPU threads for prime search", num_threads);
4848+4949+ for i in 0..num_threads {
5050+ let running = self.running.clone();
5151+ let primes_found = self.primes_found.clone();
5252+ let numbers_tested = self.numbers_tested.clone();
5353+ let handle = std::thread::Builder::new()
5454+ .name(format!("prime-worker-{}", i))
5555+ .spawn(move || {
5656+ cpu::prime_worker(
5757+ running,
5858+ primes_found,
5959+ numbers_tested,
6060+ i as u64,
6161+ num_threads as u64,
6262+ );
6363+ })
6464+ .expect("Failed to spawn CPU worker thread");
6565+ self.cpu_threads.push(handle);
6666+ }
6767+ }
6868+6969+ fn update_title(&mut self) {
7070+ self.frame_count += 1;
7171+ let now = Instant::now();
7272+ let elapsed = now.duration_since(self.last_fps_time).as_secs_f64();
7373+7474+ let current_tested = self.numbers_tested.load(Ordering::Relaxed);
7575+ let current_primes = self.primes_found.load(Ordering::Relaxed);
7676+7777+ if elapsed >= 0.5 {
7878+ self.fps = self.frame_count as f64 / elapsed;
7979+ let delta = current_tested.saturating_sub(self.last_tested_count);
8080+ self.tests_per_sec = delta as f64 / elapsed;
8181+ self.last_tested_count = current_tested;
8282+ self.frame_count = 0;
8383+ self.last_fps_time = now;
8484+ }
8585+8686+ let num_cores = num_cpus::get();
8787+8888+ let title = format!(
8989+ "\u{1F525} HEATSLOP \u{2014} GPU: {:.0} fps | CPU: {} cores \u{00D7} primes \u{2014} {} found, {} tests/s | Stay warm!",
9090+ self.fps,
9191+ num_cores,
9292+ format_number(current_primes),
9393+ format_number(self.tests_per_sec as u64),
9494+ );
9595+9696+ if let Some(window) = &self.window {
9797+ window.set_title(&title);
9898+ }
9999+ }
100100+}
101101+102102+fn format_number(n: u64) -> String {
103103+ if n >= 1_000_000_000 {
104104+ format!("{:.2}B", n as f64 / 1_000_000_000.0)
105105+ } else if n >= 1_000_000 {
106106+ format!("{:.2}M", n as f64 / 1_000_000.0)
107107+ } else if n >= 1_000 {
108108+ format!("{:.1}K", n as f64 / 1_000.0)
109109+ } else {
110110+ format!("{}", n)
111111+ }
112112+}
113113+114114+impl ApplicationHandler for App {
115115+ fn resumed(&mut self, event_loop: &ActiveEventLoop) {
116116+ if self.window.is_some() {
117117+ return;
118118+ }
119119+120120+ let window_attrs = Window::default_attributes()
121121+ .with_title("\u{1F525} HEATSLOP \u{2014} Starting up...")
122122+ .with_inner_size(PhysicalSize::new(1280u32, 720u32));
123123+124124+ let window = Arc::new(event_loop.create_window(window_attrs).unwrap());
125125+126126+ let gpu = pollster::block_on(GpuState::new(window.clone()));
127127+128128+ self.window = Some(window);
129129+ self.gpu = Some(gpu);
130130+131131+ // Start CPU workers
132132+ self.spawn_cpu_workers();
133133+ }
134134+135135+ fn window_event(
136136+ &mut self,
137137+ event_loop: &ActiveEventLoop,
138138+ _window_id: WindowId,
139139+ event: WindowEvent,
140140+ ) {
141141+ match event {
142142+ WindowEvent::CloseRequested => {
143143+ log::info!("Shutting down...");
144144+ self.running.store(false, Ordering::Relaxed);
145145+ event_loop.exit();
146146+ }
147147+ WindowEvent::Resized(new_size) => {
148148+ if let Some(gpu) = &mut self.gpu {
149149+ gpu.resize(new_size);
150150+ }
151151+ }
152152+ WindowEvent::RedrawRequested => {
153153+ self.update_title();
154154+155155+ if let Some(gpu) = &mut self.gpu {
156156+ match gpu.render() {
157157+ Ok(_) => {}
158158+ Err(wgpu::SurfaceError::Lost) => {
159159+ let size = gpu.size;
160160+ gpu.resize(size);
161161+ }
162162+ Err(wgpu::SurfaceError::OutOfMemory) => {
163163+ log::error!("Out of GPU memory!");
164164+ event_loop.exit();
165165+ }
166166+ Err(e) => {
167167+ log::warn!("Render error: {:?}", e);
168168+ }
169169+ }
170170+ }
171171+172172+ // Request another frame immediately (no vsync = max GPU throughput)
173173+ if let Some(window) = &self.window {
174174+ window.request_redraw();
175175+ }
176176+ }
177177+ WindowEvent::KeyboardInput { event, .. } => {
178178+ if event.physical_key
179179+ == winit::keyboard::PhysicalKey::Code(winit::keyboard::KeyCode::Escape)
180180+ {
181181+ self.running.store(false, Ordering::Relaxed);
182182+ event_loop.exit();
183183+ }
184184+ }
185185+ _ => {}
186186+ }
187187+ }
188188+}
189189+190190+impl Drop for App {
191191+ fn drop(&mut self) {
192192+ self.running.store(false, Ordering::Relaxed);
193193+ for handle in self.cpu_threads.drain(..) {
194194+ let _ = handle.join();
195195+ }
196196+ }
197197+}
+62
src/cpu.rs
···11+use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
22+use std::sync::Arc;
33+44+/// Test whether `n` is prime using trial division up to √n.
55+/// Deliberately not optimized — we *want* to burn CPU.
66+fn is_prime(n: u64) -> bool {
77+ if n < 2 {
88+ return false;
99+ }
1010+ if n < 4 {
1111+ return true;
1212+ }
1313+ if n % 2 == 0 || n % 3 == 0 {
1414+ return false;
1515+ }
1616+ let mut i = 5u64;
1717+ while i.saturating_mul(i) <= n {
1818+ if n % i == 0 || n % (i + 2) == 0 {
1919+ return false;
2020+ }
2121+ i += 6;
2222+ }
2323+ true
2424+}
2525+2626+/// CPU-burning worker that counts primes by brute-force trial division.
2727+///
2828+/// Each thread tests a disjoint slice of odd numbers (interleaved by stride)
2929+/// and atomically increments shared counters for primes found and numbers tested.
3030+/// Uses constant memory regardless of how long it runs.
3131+pub fn prime_worker(
3232+ running: Arc<AtomicBool>,
3333+ primes_found: Arc<AtomicU64>,
3434+ numbers_tested: Arc<AtomicU64>,
3535+ thread_id: u64,
3636+ num_threads: u64,
3737+) {
3838+ // Each thread works on odd numbers: 3 + 2*thread_id, stepping by 2*num_threads.
3939+ // Thread 0 also accounts for the prime 2 by adding 1 to its first batch.
4040+ let stride = 2 * num_threads;
4141+ let mut n = 3 + 2 * thread_id;
4242+ let batch_size = 500u64;
4343+4444+ if thread_id == 0 {
4545+ // Count prime 2 once
4646+ primes_found.fetch_add(1, Ordering::Relaxed);
4747+ }
4848+4949+ while running.load(Ordering::Relaxed) {
5050+ let mut local_primes = 0u64;
5151+5252+ for _ in 0..batch_size {
5353+ if is_prime(n) {
5454+ local_primes += 1;
5555+ }
5656+ n += stride;
5757+ }
5858+5959+ primes_found.fetch_add(local_primes, Ordering::Relaxed);
6060+ numbers_tested.fetch_add(batch_size, Ordering::Relaxed);
6161+ }
6262+}