Commit b51eb09f by Shahbaz Youssefi Committed by Commit Bot

Vulkan: Allow bindings to compute stage

Includes both binding of resources and updating push constants on the compute shader stage. Bug: angleproject:2958 Change-Id: I5686cbac81e0dd83d0e938cb40f9f9ac7d2ef48a Reviewed-on: https://chromium-review.googlesource.com/c/1355500 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent df8c1053
...@@ -957,7 +957,8 @@ void DescriptorSetLayoutDesc::unpackBindings(DescriptorSetLayoutBindingVector *b ...@@ -957,7 +957,8 @@ void DescriptorSetLayoutDesc::unpackBindings(DescriptorSetLayoutBindingVector *b
binding.binding = bindingIndex; binding.binding = bindingIndex;
binding.descriptorCount = packedBinding.count; binding.descriptorCount = packedBinding.count;
binding.descriptorType = static_cast<VkDescriptorType>(packedBinding.type); binding.descriptorType = static_cast<VkDescriptorType>(packedBinding.type);
binding.stageFlags = (VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT); binding.stageFlags =
VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT | VK_SHADER_STAGE_COMPUTE_BIT;
binding.pImmutableSamplers = nullptr; binding.pImmutableSamplers = nullptr;
bindings->push_back(binding); bindings->push_back(binding);
...@@ -1299,11 +1300,20 @@ angle::Result PipelineLayoutCache::getPipelineLayout( ...@@ -1299,11 +1300,20 @@ angle::Result PipelineLayoutCache::getPipelineLayout(
const vk::PackedPushConstantRange &pushConstantDesc = descPushConstantRanges[shaderIndex]; const vk::PackedPushConstantRange &pushConstantDesc = descPushConstantRanges[shaderIndex];
if (pushConstantDesc.size > 0) if (pushConstantDesc.size > 0)
{ {
static constexpr VkShaderStageFlagBits kShaderStages[vk::kMaxPushConstantRanges] = {
VK_SHADER_STAGE_VERTEX_BIT,
VK_SHADER_STAGE_FRAGMENT_BIT,
VK_SHADER_STAGE_GEOMETRY_BIT,
VK_SHADER_STAGE_COMPUTE_BIT,
};
static_assert(static_cast<uint32_t>(gl::ShaderType::Vertex) == 0, "Fix this table");
static_assert(static_cast<uint32_t>(gl::ShaderType::Fragment) == 1, "Fix this table");
static_assert(static_cast<uint32_t>(gl::ShaderType::Geometry) == 2, "Fix this table");
static_assert(static_cast<uint32_t>(gl::ShaderType::Compute) == 3, "Fix this table");
VkPushConstantRange pushConstantRange = {}; VkPushConstantRange pushConstantRange = {};
pushConstantRange.stageFlags = pushConstantRange.stageFlags = kShaderStages[shaderIndex];
shaderIndex == 0 ? VK_SHADER_STAGE_VERTEX_BIT : VK_SHADER_STAGE_FRAGMENT_BIT; pushConstantRange.offset = pushConstantDesc.offset;
pushConstantRange.offset = pushConstantDesc.offset; pushConstantRange.size = pushConstantDesc.size;
pushConstantRange.size = pushConstantDesc.size;
pushConstantRanges.push_back(pushConstantRange); pushConstantRanges.push_back(pushConstantRange);
} }
......
...@@ -373,9 +373,9 @@ class DescriptorSetLayoutDesc final ...@@ -373,9 +373,9 @@ class DescriptorSetLayoutDesc final
}; };
// The following are for caching descriptor set layouts. Limited to max two descriptor set layouts // The following are for caching descriptor set layouts. Limited to max two descriptor set layouts
// and two push constants. One push constant per shader stage. This can be extended in the future. // and one push constant per shader stage. This can be extended in the future.
constexpr size_t kMaxDescriptorSetLayouts = 3; constexpr size_t kMaxDescriptorSetLayouts = 3;
constexpr size_t kMaxPushConstantRanges = 2; constexpr size_t kMaxPushConstantRanges = angle::EnumSize<gl::ShaderType>();
struct PackedPushConstantRange struct PackedPushConstantRange
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment