Updated to use all uint32_t to avoid ambiguity on passing strings
This commit is contained in:
parent
5bc3ac9c06
commit
56d9a3a933
18 changed files with 65 additions and 68 deletions
|
|
@ -108,7 +108,7 @@ Algorithm::~Algorithm()
|
|||
}
|
||||
|
||||
void
|
||||
Algorithm::init(const std::vector<char>& shaderFileData,
|
||||
Algorithm::init(const std::vector<uint32_t>& shaderFileData,
|
||||
std::vector<std::shared_ptr<Tensor>> tensorParams)
|
||||
{
|
||||
SPDLOG_DEBUG("Kompute Algorithm init started");
|
||||
|
|
@ -206,14 +206,14 @@ Algorithm::createParameters(std::vector<std::shared_ptr<Tensor>>& tensorParams)
|
|||
}
|
||||
|
||||
void
|
||||
Algorithm::createShaderModule(const std::vector<char>& shaderFileData)
|
||||
Algorithm::createShaderModule(const std::vector<uint32_t>& shaderFileData)
|
||||
{
|
||||
SPDLOG_DEBUG("Kompute Algorithm createShaderModule started");
|
||||
|
||||
vk::ShaderModuleCreateInfo shaderModuleInfo(
|
||||
vk::ShaderModuleCreateFlags(),
|
||||
shaderFileData.size(),
|
||||
(uint32_t*)shaderFileData.data());
|
||||
sizeof(uint32_t) * shaderFileData.size(),
|
||||
shaderFileData.data());
|
||||
|
||||
SPDLOG_DEBUG("Kompute Algorithm Creating shader module. ShaderFileSize: {}",
|
||||
shaderFileData.size());
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ OpAlgoBase::OpAlgoBase(std::shared_ptr<vk::PhysicalDevice> physicalDevice,
|
|||
std::shared_ptr<vk::Device> device,
|
||||
std::shared_ptr<vk::CommandBuffer> commandBuffer,
|
||||
std::vector<std::shared_ptr<Tensor>>& tensors,
|
||||
const std::vector<char>& shaderDataRaw,
|
||||
const std::vector<uint32_t>& shaderDataRaw,
|
||||
const Workgroup& komputeWorkgroup,
|
||||
const Constants& specializationConstants)
|
||||
: OpAlgoBase(physicalDevice, device, commandBuffer, tensors, komputeWorkgroup, specializationConstants)
|
||||
|
|
@ -98,7 +98,7 @@ OpAlgoBase::init()
|
|||
|
||||
SPDLOG_DEBUG("Kompute OpAlgoBase fetching spirv data");
|
||||
|
||||
std::vector<char> shaderFileData = this->fetchSpirvBinaryData();
|
||||
std::vector<uint32_t> shaderFileData = this->fetchSpirvBinaryData();
|
||||
|
||||
SPDLOG_DEBUG("Kompute OpAlgoBase Initialising algorithm component");
|
||||
|
||||
|
|
@ -137,7 +137,7 @@ OpAlgoBase::postEval()
|
|||
SPDLOG_DEBUG("Kompute OpAlgoBase postSubmit called");
|
||||
}
|
||||
|
||||
std::vector<char>
|
||||
std::vector<uint32_t>
|
||||
OpAlgoBase::fetchSpirvBinaryData()
|
||||
{
|
||||
SPDLOG_DEBUG("Kompute OpAlgoBase Running fetchSpirvBinaryData");
|
||||
|
|
@ -162,7 +162,7 @@ OpAlgoBase::fetchSpirvBinaryData()
|
|||
|
||||
SPDLOG_WARN("Kompute OpAlgoBase fetched {} bytes", shaderFileSize);
|
||||
|
||||
return std::vector<char>(shaderDataRaw, shaderDataRaw + shaderFileSize);
|
||||
return std::vector<uint32_t>((uint32_t*)shaderDataRaw, (uint32_t*)(shaderDataRaw + shaderFileSize));
|
||||
} else if (this->mShaderDataRaw.size()) {
|
||||
SPDLOG_DEBUG("Kompute OpAlgoBase Reading data from data provided");
|
||||
return this->mShaderDataRaw;
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ OpAlgoLhsRhsOut::init()
|
|||
|
||||
SPDLOG_DEBUG("Kompute OpAlgoLhsRhsOut fetching spirv data");
|
||||
|
||||
std::vector<char> shaderFileData = this->fetchSpirvBinaryData();
|
||||
std::vector<uint32_t> shaderFileData = this->fetchSpirvBinaryData();
|
||||
|
||||
SPDLOG_DEBUG("Kompute OpAlgoLhsRhsOut Initialising algorithm component");
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
namespace kp {
|
||||
|
||||
std::vector<char>
|
||||
std::vector<uint32_t>
|
||||
Shader::compile_sources(const std::vector<std::string>& sources,
|
||||
const std::vector<std::string>& files,
|
||||
const std::string& entryPoint,
|
||||
|
|
@ -81,10 +81,10 @@ Shader::compile_sources(const std::vector<std::string>& sources,
|
|||
// Shutdown glslang library.
|
||||
glslang::FinalizeProcess();
|
||||
|
||||
return std::vector<char>((char*)spirv.data(), (char*)(spirv.data()+spirv.size()) );
|
||||
return spirv;
|
||||
}
|
||||
|
||||
std::vector<char>
|
||||
std::vector<uint32_t>
|
||||
Shader::compile_source(const std::string& source,
|
||||
const std::string& entryPoint,
|
||||
std::vector<std::pair<std::string,std::string>> definitions) {
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public:
|
|||
* @specalizationInstalces The specialization parameters to pass to the function
|
||||
* processing
|
||||
*/
|
||||
void init(const std::vector<char>& shaderFileData,
|
||||
void init(const std::vector<uint32_t>& shaderFileData,
|
||||
std::vector<std::shared_ptr<Tensor>> tensorParams);
|
||||
|
||||
/**
|
||||
|
|
@ -83,7 +83,7 @@ private:
|
|||
Constants mSpecializationConstants;
|
||||
|
||||
// Create util functions
|
||||
void createShaderModule(const std::vector<char>& shaderFileData);
|
||||
void createShaderModule(const std::vector<uint32_t>& shaderFileData);
|
||||
void createPipeline();
|
||||
|
||||
// Parameters
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@ namespace kp {
|
|||
|
||||
class Shader {
|
||||
public:
|
||||
static std::vector<char> compile_sources(
|
||||
static std::vector<uint32_t> compile_sources(
|
||||
const std::vector<std::string>& sources,
|
||||
const std::vector<std::string>& files = {},
|
||||
const std::string& entryPoint = "main",
|
||||
std::vector<std::pair<std::string,std::string>> definitions = {});
|
||||
|
||||
static std::vector<char> compile_source(
|
||||
static std::vector<uint32_t> compile_source(
|
||||
const std::string& source,
|
||||
const std::string& entryPoint = "main",
|
||||
std::vector<std::pair<std::string,std::string>> definitions = {});
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ class OpAlgoBase : public OpBase
|
|||
std::shared_ptr<vk::Device> device,
|
||||
std::shared_ptr<vk::CommandBuffer> commandBuffer,
|
||||
std::vector<std::shared_ptr<Tensor>>& tensors,
|
||||
const std::vector<char>& shaderDataRaw,
|
||||
const std::vector<uint32_t>& shaderDataRaw,
|
||||
const Workgroup& komputeWorkgroup = {},
|
||||
const Constants& specializationConstants = {});
|
||||
|
||||
|
|
@ -135,9 +135,9 @@ class OpAlgoBase : public OpBase
|
|||
Workgroup mKomputeWorkgroup;
|
||||
|
||||
std::string mShaderFilePath; ///< Optional member variable which can be provided for the OpAlgoBase to find the data automatically and load for processing
|
||||
std::vector<char> mShaderDataRaw; ///< Optional member variable which can be provided to contain either the raw shader content or the spirv binary content
|
||||
std::vector<uint32_t> mShaderDataRaw; ///< Optional member variable which can be provided to contain either the raw shader content or the spirv binary content
|
||||
|
||||
virtual std::vector<char> fetchSpirvBinaryData();
|
||||
virtual std::vector<uint32_t> fetchSpirvBinaryData();
|
||||
};
|
||||
|
||||
} // End namespace kp
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ class OpMult : public OpAlgoBase
|
|||
SPDLOG_DEBUG("Kompute OpMult constructor with params");
|
||||
|
||||
#ifndef RELEASE
|
||||
this->mShaderFilePath = "shaders/glsl/opmult.comp";
|
||||
this->mShaderFilePath = "shaders/glsl/opmult.comp.spv";
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -59,15 +59,15 @@ class OpMult : public OpAlgoBase
|
|||
* If RELEASE=1 it will be using the static version of the shader which is
|
||||
* loaded using this file directly. Otherwise it should not override the function.
|
||||
*/
|
||||
std::vector<char> fetchSpirvBinaryData() override
|
||||
std::vector<uint32_t> fetchSpirvBinaryData() override
|
||||
{
|
||||
SPDLOG_WARN(
|
||||
"Kompute OpMult Running shaders directly from header");
|
||||
|
||||
return std::vector<char>(
|
||||
shader_data::shaders_glsl_opmult_comp_spv,
|
||||
shader_data::shaders_glsl_opmult_comp_spv +
|
||||
kp::shader_data::shaders_glsl_opmult_comp_spv_len);
|
||||
return std::vector<uint32_t>(
|
||||
(uint32_t*)shader_data::shaders_glsl_opmult_comp_spv,
|
||||
(uint32_t*)(shader_data::shaders_glsl_opmult_comp_spv +
|
||||
kp::shader_data::shaders_glsl_opmult_comp_spv_len));
|
||||
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue