diff options
| author | Yong He <yonghe@outlook.com> | 2021-03-24 13:57:55 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-24 13:57:55 -0700 |
| commit | 98afb421f408aa8651afff3dba1b21fad71131fe (patch) | |
| tree | a8610d12ac7d74a8772cb6ecdd810da8216baa67 /tools/gfx/vulkan/vk-util.cpp | |
| parent | d0f7b7f0ed1d0d1388ce944cd1ad906bbd9afb35 (diff) | |
Reimplement Vulkan shader objects. (#1764)
* Reimplement Vulkan shader objects.
This change reimplements Vulkan shader objects in the `gfx` layer so that it is no longer layered on top of the `DescriptorSet` abstraction. Since this is the last implementation that uses `DescriptorSet`, the change also removes all `DescriptorSet` related API from public `gfx` interface.
The Vulkan implementation now passes all test cases, but it still have two issues:
1. The PushConstant setting is not correct, this is because we don't seem to be able to get correct reflection data about the size of push constants for an entry-point.
2. The `shader-toy` example can't run on Vulkan, because it currently sets nullptr to `Texture` bindings, and this change doesn't properly handle setting resource to null in `ShaderObject`s yet. If we can use the `nullDescriptor` feature on vulkan, this implementation will be simple. However we still want to decide whether we want to use a Vulkan 1.2 feature for this.
* Fix up
Diffstat (limited to 'tools/gfx/vulkan/vk-util.cpp')
| -rw-r--r-- | tools/gfx/vulkan/vk-util.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tools/gfx/vulkan/vk-util.cpp b/tools/gfx/vulkan/vk-util.cpp index 218801d7a..46ffb01fd 100644 --- a/tools/gfx/vulkan/vk-util.cpp +++ b/tools/gfx/vulkan/vk-util.cpp @@ -30,6 +30,53 @@ namespace gfx { return (res == VK_SUCCESS) ? SLANG_OK : SLANG_FAIL; } +VkShaderStageFlags VulkanUtil::getShaderStage(SlangStage stage) +{ + switch (stage) + { + case SLANG_STAGE_ANY_HIT: + return VK_SHADER_STAGE_ANY_HIT_BIT_KHR; + case SLANG_STAGE_CALLABLE: + return VK_SHADER_STAGE_CALLABLE_BIT_KHR; + case SLANG_STAGE_CLOSEST_HIT: + return VK_SHADER_STAGE_CLOSEST_HIT_BIT_KHR; + case SLANG_STAGE_COMPUTE: + return VK_SHADER_STAGE_COMPUTE_BIT; + case SLANG_STAGE_DOMAIN: + return VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; + case SLANG_STAGE_FRAGMENT: + return VK_SHADER_STAGE_FRAGMENT_BIT; + case SLANG_STAGE_GEOMETRY: + return VK_SHADER_STAGE_GEOMETRY_BIT; + case SLANG_STAGE_HULL: + return VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; + case SLANG_STAGE_INTERSECTION: + return VK_SHADER_STAGE_INTERSECTION_BIT_KHR; + case SLANG_STAGE_RAY_GENERATION: + return VK_SHADER_STAGE_RAYGEN_BIT_KHR; + case SLANG_STAGE_VERTEX: + return VK_SHADER_STAGE_VERTEX_BIT; + default: + assert(!"unsupported stage."); + return VkShaderStageFlags(-1); + } +} + +VkPipelineBindPoint VulkanUtil::getPipelineBindPoint(PipelineType pipelineType) +{ + switch (pipelineType) + { + case gfx::PipelineType::Graphics: + return VK_PIPELINE_BIND_POINT_GRAPHICS; + case gfx::PipelineType::Compute: + return VK_PIPELINE_BIND_POINT_COMPUTE; + case gfx::PipelineType::RayTracing: + return VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR; + default: + return VkPipelineBindPoint(-1); + } +} + /* static */Slang::Result VulkanUtil::handleFail(VkResult res) { if (res != VK_SUCCESS) |
