-
Notifications
You must be signed in to change notification settings - Fork 62
CMake Inteface implementation #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
EndrII
wants to merge
9
commits into
KdotJPG:master
Choose a base branch
from
QuasarApp:main
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d3afe8f
Improve rust version performance
qarmin 56c9b2b
Remove unnecessary collect
qarmin 2fc0f55
Precompute all Lookup Tables at Compile Time
CryZe 89929a5
Make std optional, but disabled by default
qarmin 245163b
Merge pull request #1 from qarmin/improve_rust_speed
EndrII 47dd58b
added cmake support
EndrII 07dfcc6
added CMake Inteface implementation
EndrII 48cf0c2
Apply suggestions from code review
EndrII f321f1e
update Rust configure tool
EndrII File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| target | ||
| Cargo.lock |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| cmake_minimum_required(VERSION 3.19) | ||
|
|
||
| set(CURRENT_PROJECT "OpenSimplex2Interface") | ||
|
|
||
| option(OPENSIMPLEX_C "Enable build old C implementation instead Rust" OFF) | ||
| option(OPENSIMPLEX_RUST "Enable build old C implementation instead Rust" ON) | ||
|
|
||
|
|
||
| add_library(${CURRENT_PROJECT} INTERFACE) | ||
|
|
||
| if (OPENSIMPLEX_RUST) | ||
|
|
||
| include(FetchContent) | ||
|
|
||
| FetchContent_Declare( | ||
| Corrosion | ||
| GIT_REPOSITORY https://github.com/corrosion-rs/corrosion.git | ||
| GIT_TAG v0.5 | ||
| ) | ||
| FetchContent_MakeAvailable(Corrosion) | ||
| corrosion_import_crate(MANIFEST_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Cargo.toml ALL_FEATURES) | ||
|
|
||
| target_link_libraries(${CURRENT_PROJECT} INTERFACE "opensimplex2") | ||
| target_include_directories(${CURRENT_PROJECT} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) | ||
|
|
||
| endif() | ||
|
|
||
| if (OPENSIMPLEX_C) | ||
|
|
||
| set(SOURCE_CPP | ||
| "${CMAKE_CURRENT_SOURCE_DIR}/_old/c/OpenSimplex2F.c" | ||
| "${CMAKE_CURRENT_SOURCE_DIR}/_old/c/OpenSimplex2F.h" | ||
| ) | ||
|
|
||
| add_library(${CURRENT_PROJECT}C ${SOURCE_CPP}) | ||
| target_include_directories(${CURRENT_PROJECT}C PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/_old/") | ||
| target_compile_options(${CURRENT_PROJECT}C PRIVATE -Wall -Wextra --pedantic) | ||
| target_link_libraries(${CURRENT_PROJECT} INTERFACE ${CURRENT_PROJECT}C) | ||
|
|
||
| endif() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| use std::time::Instant; | ||
|
|
||
| fn main() { | ||
| const SEED: i64 = 0; | ||
|
|
||
| let _ = opensimplex2::fast::noise2(SEED, 0.0, 0.0); | ||
|
|
||
| for _ in 0..10 { | ||
| let iteration_time = Instant::now(); | ||
| let mut res = 0.0; // To not optimize away the loop | ||
|
|
||
| for x in 0..8000 { | ||
| for y in 0..8000 { | ||
| res += opensimplex2::fast::noise2(SEED, x as f64, y as f64); | ||
| } | ||
| } | ||
|
|
||
| println!( | ||
| "Rust Impl 2D: {} msec (Res: {res})", | ||
| iteration_time.elapsed().as_millis() | ||
| ); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.