-
Notifications
You must be signed in to change notification settings - Fork 184
Moved management of shader module creation and lifetime to its own class. #444
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
softcookiepp
wants to merge
13
commits into
KomputeProject:master
Choose a base branch
from
softcookiepp:master
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 all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
18d6363
update internal gtest to v1.17.0 (#437)
TinyTinni cf3363b
moved shader module creation to its own class in preparation for cach…
a9d99bd
Removed Cache.cpp, as it will not be used.
softcookiepp 4fff195
completely forgot to remove Cache.hpp, as it is not used
softcookiepp 67ba9c3
as you wish
softcookiepp ff7be34
Fixed incorrect kp::Manager usage in TestAsyncOperations.cpp
softcookiepp c2518a7
Fix incorrect creation of python arrays in Tensor.data (#440)
robquill fdcff9f
Updated to pybind 3.0.0 (#431)
axsaucedo b6b19e4
Clarify status of llama.cpp in README (#446)
axsaucedo d94ea8e
Tests pass now
softcookiepp 7abb728
removed mSpirv from kp::Algorithm
softcookiepp f89f493
revered a silly change made based on silly assumptions
softcookiepp 3552b49
Merge branch 'KomputeProject:master' into master
softcookiepp 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| #include "kompute/Shader.hpp" | ||
|
|
||
| namespace kp { | ||
|
|
||
| Shader::Shader(const std::shared_ptr<vk::Device>& device, | ||
| const std::vector<uint32_t>& spv) : | ||
| mDevice(device) | ||
| { | ||
| KP_LOG_DEBUG("Kompute Module constructor started"); | ||
| KP_LOG_DEBUG("Kompute Module Creating shader module. ShaderFileSize: {}", | ||
| spv.size()); | ||
| vk::ShaderModuleCreateInfo shaderModuleInfo(vk::ShaderModuleCreateFlags(), | ||
| sizeof(uint32_t) * spv.size(), spv.data()); | ||
| this->mDevice->createShaderModule( | ||
| &shaderModuleInfo, nullptr, &(this->mShaderModule) ); | ||
| KP_LOG_DEBUG("Kompute Module constructor success"); | ||
| } | ||
|
|
||
| const vk::ShaderModule& Shader::getShaderModule() | ||
axsaucedo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| if (this->mDestroyed) | ||
| throw std::runtime_error("Attempting to get vk::ShaderModule from destroyed kp::Shader instance"); | ||
| return this->mShaderModule; | ||
| } | ||
|
|
||
| void Shader::destroy() | ||
| { | ||
| KP_LOG_DEBUG("Kompute Module destructor started"); | ||
| KP_LOG_DEBUG("Kompute Module Destroying shader module"); | ||
| if (!this->mDestroyed) | ||
| { | ||
| this->mDestroyed = true; | ||
| this->mDevice->destroyShaderModule(this->mShaderModule); | ||
| } | ||
| KP_LOG_DEBUG("Kompute Module destructor success"); | ||
| } | ||
|
|
||
| Shader::~Shader() | ||
| { | ||
| this->destroy(); | ||
| } | ||
|
|
||
| } // end namespace kp | ||
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,44 @@ | ||
| #pragma once | ||
|
|
||
| #include "kompute/Core.hpp" | ||
| #include "logger/Logger.hpp" | ||
| #include <memory> | ||
|
|
||
| namespace kp { | ||
|
|
||
| // forward declarations for std::shared_from_this | ||
| class Shader; | ||
|
|
||
| /* | ||
| * Wrapper for Vulkan's shader modules. | ||
| */ | ||
| class Shader | ||
| { | ||
| // not-owned resources | ||
| std::shared_ptr<vk::Device> mDevice; | ||
|
|
||
| // owned resources | ||
| vk::ShaderModule mShaderModule; | ||
| bool mDestroyed = false; | ||
|
|
||
| public: | ||
|
|
||
| /** | ||
| * Constructor accepting a device and a SPIR-V binary | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment conventions should align to rest of codebase - see manager.hpp |
||
| * @param device The vk::Device for the shader module to be compiled for | ||
| * @param spv The SPIR-V binary | ||
| **/ | ||
| Shader(const std::shared_ptr<vk::Device>& device, | ||
| const std::vector<uint32_t>& spv); | ||
|
|
||
| /** | ||
| * getter for mShaderModule | ||
| **/ | ||
| const vk::ShaderModule& getShaderModule(); | ||
|
|
||
| void destroy(); | ||
|
|
||
| ~Shader(); | ||
| }; | ||
|
|
||
| } // End namespace kp | ||
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
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.