Commit ccaa8e84 by Nicolas Capens Committed by Nicolas Capens

Pass only descriptor data to shader execution

vk::DescriptorSet has a header which has a pointer to the descriptor set layout, which is needed for vkUpdateDescriptorSets. This information should not be available to shaders during execution. Bug: b/152227757 Change-Id: I088828a28ab4ed75ae84fb3f103455f70a8bc051 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/43968 Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarBen Clayton <bclayton@google.com>
parent 93613e11
......@@ -1108,7 +1108,7 @@ public:
auto dynamicOffsetBase = pipelineLayout->getDynamicOffsetBase(set);
ASSERT_OR_RETURN(dynamicOffsetBase + dynamicOffsetCount <= vk::MAX_DESCRIPTOR_SET_COMBINED_BUFFERS_DYNAMIC);
pipelineState.descriptorSets[set] = descriptorSet;
pipelineState.descriptorSets[set] = descriptorSet->data;
for(uint32_t i = 0; i < dynamicOffsetCount; i++)
{
pipelineState.descriptorDynamicOffsets[dynamicOffsetBase + i] = dynamicOffsets[i];
......
......@@ -18,6 +18,7 @@
// Intentionally not including VkObject.hpp here due to b/127920555
#include <array>
#include <cstdint>
#include <memory>
namespace vk {
......@@ -37,7 +38,7 @@ public:
return static_cast<DescriptorSet *>(static_cast<void *>(object));
}
using Bindings = std::array<vk::DescriptorSet *, vk::MAX_BOUND_DESCRIPTOR_SETS>;
using Bindings = std::array<uint8_t *, vk::MAX_BOUND_DESCRIPTOR_SETS>;
using DynamicOffsets = std::array<uint32_t, vk::MAX_DESCRIPTOR_SET_COMBINED_BUFFERS_DYNAMIC>;
DescriptorSetHeader header;
......
......@@ -19,9 +19,9 @@
#include "VkDescriptorSet.hpp"
#include "VkImageView.hpp"
#include "VkSampler.hpp"
#include "System/Types.hpp"
#include <algorithm>
#include <cstddef>
#include <cstring>
namespace {
......@@ -115,8 +115,8 @@ size_t DescriptorSetLayout::GetDescriptorSize(VkDescriptorType type)
size_t DescriptorSetLayout::getDescriptorSetAllocationSize() const
{
// vk::DescriptorSet has a layout member field.
return sw::align<alignof(DescriptorSet)>(OFFSET(DescriptorSet, data) + getDescriptorSetDataSize());
// vk::DescriptorSet has a header with a pointer to the layout.
return sw::align<alignof(DescriptorSet)>(offsetof(DescriptorSet, data) + getDescriptorSetDataSize());
}
size_t DescriptorSetLayout::getDescriptorSetDataSize() const
......@@ -196,7 +196,7 @@ size_t DescriptorSetLayout::getBindingOffset(uint32_t binding, size_t arrayEleme
{
uint32_t index = getBindingIndex(binding);
auto typeSize = GetDescriptorSize(bindings[index].descriptorType);
return bindingOffsets[index] + OFFSET(DescriptorSet, data[0]) + (typeSize * arrayElement);
return bindingOffsets[index] + (typeSize * arrayElement);
}
bool DescriptorSetLayout::isDynamic(VkDescriptorType type)
......
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