UPdated examples and documentations to not require glsl deps
This commit is contained in:
parent
15346ee505
commit
96768a3302
10 changed files with 85 additions and 27 deletions
|
|
@ -55,7 +55,8 @@ The example below shows how you can enable the "VK_EXT_shader_atomic_float" exte
|
|||
atomicAdd(pa[2], pcs.z);
|
||||
})");
|
||||
|
||||
std::vector<uint32_t> spirv = kp_test_utils::Shader::compileSource(shader);
|
||||
// See shader documentation section for compileSource
|
||||
std::vector<uint32_t> spirv = compileSource(shader);
|
||||
|
||||
std::shared_ptr<kp::Sequence> sq = nullptr;
|
||||
|
||||
|
|
@ -102,7 +103,8 @@ We also provide tools that allow you to `convert shaders into C++ headers <https
|
|||
throw std::runtime_error("Kompute OpMult expected 3 tensors but got " + tensors.size());
|
||||
}
|
||||
|
||||
std::vector<uint32_t> spirv = kp_test_utils::Shader::compileSource(R"(
|
||||
// See shader documentation section for compileSource
|
||||
std::vector<uint32_t> spirv = compileSource(R"(
|
||||
#version 450
|
||||
|
||||
layout(set = 0, binding = 0) buffer tensorLhs {
|
||||
|
|
@ -215,7 +217,8 @@ In this case we create a shader that should take a couple of milliseconds to run
|
|||
}
|
||||
)");
|
||||
|
||||
auto algo = mgr.algorithm({tensor}, kp_test_utils::Shader::compileSource(shader));
|
||||
// See shader documentation section for compileSource
|
||||
auto algo = mgr.algorithm({tensor}, compileSource(shader));
|
||||
|
||||
Now we are able to run the await function on the default sequence.
|
||||
|
||||
|
|
@ -361,7 +364,8 @@ Similar to the asyncrhonous usecase above, we can still run synchronous commands
|
|||
}
|
||||
)");
|
||||
|
||||
std::vector<uint32_t> spirv = kp_test_utils::Shader::compileSource(shader);
|
||||
// See shader documentation section for compileSource
|
||||
std::vector<uint32_t> spirv = compileSource(shader);
|
||||
|
||||
std::shared_ptr<kp::Algorithm> algo = mgr.algorithm({tensorA, tenssorB}, spirv);
|
||||
|
||||
|
|
|
|||
|
|
@ -69,8 +69,6 @@ Compile Flags
|
|||
- Enable debug build including debug flags (enabled by cmake debug build)
|
||||
* - -DKOMPUTE_DISABLE_VK_DEBUG_LAYERS
|
||||
- Disable the debug Vulkan SDK Layers, mainly used for android builds
|
||||
* - -DKOMPUTE_DISABLE_SHADER_UTILS
|
||||
- Disable the shader utils and skip adding glslang as dependency
|
||||
|
||||
Other CMake Flags
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
|
|
|||
|
|
@ -38,10 +38,7 @@ Running on the CPU
|
|||
|
||||
We use `Swiftshader <https://github.com/google/swiftshader>`_ to enable us to run the Kompute framework directly on the CPU for the CI tests.
|
||||
|
||||
Even though Swiftshader is optimized to function as a high-performance CPU backend for the Vulkan SDK, there are several limitations, the most notable in context of Kompute are:
|
||||
|
||||
* Loading files (spirv or text) leads to segfault
|
||||
* Loading raw text string shaders leads to segfault
|
||||
Even though Swiftshader is optimized to function as a high-performance CPU backend for the Vulkan SDK, there are several limitations, the most notable are limitations in extensions.
|
||||
|
||||
This is one of the main reason why only a subset of the tests are run in the CI.
|
||||
|
||||
|
|
|
|||
|
|
@ -119,13 +119,4 @@ The :class:`kp::OpMemoryBarrier` is a tensor only operation which adds memory ba
|
|||
.. doxygenclass:: kp::OpTensorSyncDevice
|
||||
:members:
|
||||
|
||||
Shader
|
||||
--------
|
||||
|
||||
The :class:`kp_test_utils::Shader` class contains a set of utilities to compile and process shaders.
|
||||
|
||||
.. doxygenclass:: kp_test_utils::Shader
|
||||
:members:
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,29 @@
|
|||
Processing Shaders with Kompute
|
||||
=====================
|
||||
|
||||
Demo / testing function to compile shaders
|
||||
----------------------------------
|
||||
|
||||
GLSLANG was initially integrated as part of the framework but it now has been removed due to the license of the glslang pre-processor being under a custom NVIDIA license which explicitly excludes grant of any licenses to NVIDIA's patents in the preprocessor.
|
||||
|
||||
For users that are looking to quickly test the processors it is possible to use the function that is provided in the examples which provides a (non-thread-safe / non-robust) implementation that compiles a shader string into spirv bytes. It is not recommended to use in production but it does enable for faster iteration cycles during development.
|
||||
|
||||
.. code-block:: cpp
|
||||
:linenos:
|
||||
static std::vector<uint32_t>
|
||||
compileSource(
|
||||
const std::string& source)
|
||||
{
|
||||
if (system(std::string("glslangValidator --stdin -S comp -V -o tmp_kp_shader.comp.spv << END
|
||||
" + source + "
|
||||
END").c_str()))
|
||||
throw std::runtime_error("Error running glslangValidator command");
|
||||
std::ifstream fileStream("tmp_kp_shader.comp.spv", std::ios::binary);
|
||||
std::vector<char> buffer;
|
||||
buffer.insert(buffer.begin(), std::istreambuf_iterator<char>(fileStream), {});
|
||||
return {(uint32_t*)buffer.data(), (uint32_t*)(buffer.data() + buffer.size())};
|
||||
}
|
||||
|
||||
Converting Shaders into C / C++ Header Files
|
||||
----------------------------------
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue