-
Notifications
You must be signed in to change notification settings - Fork 9
Create the Rendering Hardware Abstraction (RHI) #16
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
Draft
AR-DEV-1
wants to merge
8
commits into
Redot-Engine:master
Choose a base branch
from
AR-DEV-1:rendering-hardware-abstraction
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.
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6458806
Start workin' on RHI
AR-DEV-1 b58cba3
Idk how I missed these, they coulda been major security vulnerabilities
AR-DEV-1 7b92c6b
Do what CodeRabbit said & add Wayland support (still doesn't work)
AR-DEV-1 64c0d2f
Fix includes
AR-DEV-1 c955c7d
Add uniform management
AR-DEV-1 eebea86
Add texture loadin' support
AR-DEV-1 b433315
Add framebuffer handles, render targets & dynamic/transient buffers s…
AR-DEV-1 436c405
Add depth & stencil testing, Alpha blending modes, dedicated sampler …
AR-DEV-1 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
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
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 |
|---|---|---|
| @@ -1,3 +1,24 @@ | ||
| add_modules_library(definitions) | ||
| add_modules_library(math) | ||
| target_link_libraries(math PUBLIC definitions) | ||
| add_modules_library(io) | ||
|
|
||
| target_link_libraries(math PUBLIC definitions) | ||
| target_link_libraries(io PUBLIC definitions stb_image) | ||
|
|
||
| add_library(image_loader SHARED) | ||
|
|
||
| target_sources(image_loader | ||
| PUBLIC | ||
| FILE_SET CXX_MODULES FILES | ||
| io/image_loader.cppm | ||
| ) | ||
|
|
||
| target_sources(image_loader | ||
| PRIVATE | ||
| io/image_loader.cpp | ||
| ) | ||
|
|
||
| target_link_libraries(image_loader | ||
| PRIVATE | ||
| stb_image | ||
| ) |
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,36 @@ | ||
| module; | ||
|
|
||
| import std; | ||
|
|
||
| module core.io.filesystem; | ||
|
|
||
| namespace draco::core::io::filesystem | ||
| { | ||
| std::vector<std::uint8_t> load_binary(const std::string& path) | ||
| { | ||
| // Open at the end (ate) to get size and in binary mode | ||
| std::ifstream file(path, std::ios::binary | std::ios::ate); | ||
|
|
||
| if (!file.is_open()) { | ||
| std::println("Error: Could not open file at: {}", path); | ||
| // Return an empty vector | ||
| return {}; | ||
| } | ||
|
|
||
| std::streamsize size = file.tellg(); | ||
| if (size <= 0) { | ||
| std::println("Error: File is empty or unreadable: {}", path); | ||
| return {}; | ||
| } | ||
|
|
||
| file.seekg(0, std::ios::beg); | ||
|
|
||
| std::vector<std::uint8_t> buffer(static_cast<std::size_t>(size)); | ||
| if (file.read(reinterpret_cast<char*>(buffer.data()), size)) { | ||
| return buffer; | ||
| } | ||
|
|
||
| std::println("Error: Failed to read file contents: {}", path); | ||
| return {}; | ||
|
AR-DEV-1 marked this conversation as resolved.
|
||
| } | ||
| } | ||
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,9 @@ | ||
| export module core.io.filesystem; | ||
|
|
||
| import std; | ||
|
|
||
| export namespace draco::core::io::filesystem | ||
| { | ||
| // Returns a buffer of the file data | ||
| std::vector<std::uint8_t> load_binary(const std::string& path); | ||
| } |
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,46 @@ | ||
| module; | ||
|
|
||
| #define STB_IMAGE_IMPLEMENTATION | ||
| #include <stb_image.h> | ||
|
|
||
| #include <filesystem> | ||
|
|
||
| module core.io.image_loader; | ||
|
|
||
| // TODO: I'm too lazy to write code so we need somethin' better | ||
|
|
||
| namespace draco::core::io::image_loader | ||
| { | ||
| ImageData load_image(const std::filesystem::path& path) | ||
| { | ||
| ImageData result; | ||
|
|
||
| if (!std::filesystem::exists(path)) { | ||
| std::println("Error: Image path does not exist: {}", path.string()); | ||
| return result; | ||
| } | ||
|
|
||
| int width, height, channels; | ||
| // STBI_rgb_alpha forces the output to be 4 bytes per pixel (RGBA) | ||
| unsigned char* data = stbi_load(path.string().c_str(), &width, &height, &channels, STBI_rgb_alpha); | ||
|
|
||
| if (!data) { | ||
| std::println("Error: Failed to decode image: {}", path.string()); | ||
| return result; | ||
| } | ||
|
|
||
| // Calculate the total size: width * height * 4 (RGBA) | ||
| size_t size = static_cast<size_t>(width) * height * 4; | ||
|
|
||
| result.pixels.assign(data, data + size); | ||
| result.width = static_cast<uint16_t>(width); | ||
| result.height = static_cast<uint16_t>(height); | ||
| result.channels = 4; | ||
| result.is_valid = true; | ||
|
|
||
| // Free the memory allocated by stb | ||
| stbi_image_free(data); | ||
|
|
||
| return result; | ||
| } | ||
| } |
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 @@ | ||
| module; | ||
|
|
||
| #include <cstdint> | ||
| #include <vector> | ||
|
|
||
| export module core.io.image_loader; | ||
|
|
||
| import std; | ||
|
|
||
| export namespace draco::core::io::image_loader | ||
| { | ||
| struct ImageData | ||
| { | ||
| std::vector<uint8_t> pixels; | ||
| uint16_t width = 0; | ||
| uint16_t height = 0; | ||
| uint8_t channels = 0; | ||
| bool is_valid = false; | ||
| }; | ||
|
|
||
| // Load an image file (PNG, JPG, etc) & decode it to raw RGBA8 | ||
| ImageData load_image(const std::filesystem::path& path); | ||
| } |
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.