Skip to content

Commit

Permalink
Merge pull request #8 from vini-fda/fix-srgb-color
Browse files Browse the repository at this point in the history
Fix inconsistent colors between Windows and Linux
  • Loading branch information
vini-fda authored Jul 3, 2023
2 parents e398a86 + 432f066 commit db56577
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "heat-wgpu"
version = "0.2.0"
version = "0.2.1"
edition = "2021"

[dependencies]
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,10 @@ cargo run --release
- LeVeque, R. J. (2007). *Finite difference methods for ordinary and partial differential equations: steady-state and time-dependent problems. Society for Industrial and Applied Mathematics*.
- Shewchuk, J. R. (1994). [*An introduction to the conjugate gradient method without the agonizing pain*](https://www.cs.cmu.edu/~quake-papers/painless-conjugate-gradient.pdf).
- Bell, N., & Garland, M. (2008). *Efficient sparse matrix-vector multiplication on CUDA (Vol. 2, No. 5). Nvidia Technical Report NVR-2008-004, Nvidia Corporation*.
- GPU Gems 2: Programming Techniques for High-Performance Graphics and General-Purpose Computation. 2005. Addison-Wesley Professional.
- Specifically [*Chapter 44: A GPU Framework for Solving Systems of Linear Equations*](https://developer.nvidia.com/gpugems/gpugems2/part-vi-simulation-and-numerical-algorithms/chapter-44-gpu-framework-solving), which also cites the following papers:
- Bolz, J., I. Farmer, E. Grinspun, and P. Schröder. 2003. "Sparse Matrix Solvers on the GPU: Conjugate Gradients and Multigrid." *ACM Transactions on Graphics (Proceedings of SIGGRAPH 2003)* 22(3), pp. 917–924.
- Krüger, Jens, and Rüdiger Westermann. 2003. "Linear Algebra Operators for GPU Implementation of Numerical Algorithms." *ACM Transactions on Graphics (Proceedings of SIGGRAPH 2003)* 22(3), pp. 908–916.
- Harris, M. (2007). *Optimizing parallel reduction in CUDA. Nvidia developer technology, 2*(4), 70.
- Mikhailov, A. (2019). [Turbo, An Improved Rainbow Colormap for Visualization](https://ai.googleblog.com/2019/08/turbo-improved-rainbow-colormap-for.html).
- [WebGPU specification](https://gpuweb.github.io/gpuweb/).
3 changes: 3 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ impl App {
.await
.unwrap();
println!("Adapter: {:?}", adapter.get_info());
println!("Surface: {:?}", surface.get_capabilities(&adapter));
//device and queue
let (device, queue) = adapter
.request_device(
Expand All @@ -83,8 +84,10 @@ impl App {
.get_default_config(&adapter, size.width, size.height)
.expect("Surface isn't supported by the adapter.");
config.present_mode = wgpu::PresentMode::Fifo;
config.format = wgpu::TextureFormat::Bgra8Unorm;
let surface_view_format = config.format.add_srgb_suffix();
config.view_formats.push(surface_view_format);
println!("Config: {:?}", config);
surface.configure(&device, &config);

// ------ GPU Compute config ------
Expand Down
2 changes: 2 additions & 0 deletions src/shaders/render.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {

// Turbo colormap (polynomial approximation)
// reference: https://ai.googleblog.com/2019/08/turbo-improved-rainbow-colormap-for.html
// Original LUT: https://gist.github.com/mikhailov-work/ee72ba4191942acecc03fe6da94fc73f
// Authors: Anton Mikhailov ([email protected]), Ruofei Du ([email protected])
fn TurboColormap(x: f32) -> vec3<f32> {
let kRedVec4: vec4<f32> = vec4<f32>(0.13572138, 4.61539260, -42.66032258, 132.13108234);
let kGreenVec4: vec4<f32> = vec4<f32>(0.09140261, 2.19418839, 4.84296658, -14.18503333);
Expand Down

0 comments on commit db56577

Please sign in to comment.