-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vk protected content command buffer #8241
base: main
Are you sure you want to change the base?
Changes from 27 commits
6218164
e265850
8671617
d49554d
4fccd95
96cba96
abe8a49
c81cedd
387942c
0fdf1ca
8bc4d3a
9e92193
f3afc25
0a2d9af
adc0197
b51a46d
01a2480
58dc0e5
c42b76a
c2f3b1b
48bb10a
0478533
dcdbbdb
46b77ec
8797b0a
b0d6799
c0e0048
6d98715
d8811f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -185,8 +185,9 @@ struct PushConstantDescription { | |
|
||
uint32_t getVkRangeCount() const noexcept { return mRangeCount; } | ||
|
||
void write(VulkanCommands* commands, VkPipelineLayout layout, backend::ShaderStage stage, | ||
uint8_t index, backend::PushConstantVariant const& value); | ||
void write(VulkanCommands* commands, bool isProtected, VkPipelineLayout layout, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's not change VulkanHandles in this PR |
||
backend::ShaderStage stage, uint8_t index, | ||
backend::PushConstantVariant const& value); | ||
|
||
private: | ||
static constexpr uint32_t ENTRY_SIZE = sizeof(uint32_t); | ||
|
@@ -218,9 +219,11 @@ struct VulkanProgram : public HwProgram, VulkanResource { | |
return mInfo->pushConstantDescription.getVkRanges(); | ||
} | ||
|
||
inline void writePushConstant(VulkanCommands* commands, VkPipelineLayout layout, | ||
backend::ShaderStage stage, uint8_t index, backend::PushConstantVariant const& value) { | ||
mInfo->pushConstantDescription.write(commands, layout, stage, index, value); | ||
inline void writePushConstant(VulkanCommands* commands, bool isProtected, | ||
VkPipelineLayout layout, backend::ShaderStage stage, uint8_t index, | ||
backend::PushConstantVariant const& value) { | ||
mInfo->pushConstantDescription.write(commands, isProtected, layout, | ||
stage, index, value); | ||
} | ||
|
||
#if FVK_ENABLED_DEBUG_SAMPLER_NAME | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ namespace filament::backend { | |
namespace { | ||
|
||
std::tuple<VkImage, VkDeviceMemory> createImageAndMemory(VulkanContext const& context, | ||
VkDevice device, VkExtent2D extent, VkFormat format) { | ||
VkDevice device, VkExtent2D extent, VkFormat format, bool isProtected) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you do this in a separate PR? |
||
bool const isDepth = isVkDepthFormat(format); | ||
// Filament expects blit() to work with any texture, so we almost always set these usage flags | ||
// (see copyFrame() and readPixels()). | ||
|
@@ -38,6 +38,7 @@ std::tuple<VkImage, VkDeviceMemory> createImageAndMemory(VulkanContext const& co | |
|
||
VkImageCreateInfo imageInfo { | ||
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, | ||
.flags = isProtected ? VK_IMAGE_CREATE_PROTECTED_BIT : VkImageCreateFlags(0), | ||
.imageType = VK_IMAGE_TYPE_2D, | ||
.format = format, | ||
.extent = {extent.width, extent.height, 1}, | ||
|
@@ -59,7 +60,8 @@ std::tuple<VkImage, VkDeviceMemory> createImageAndMemory(VulkanContext const& co | |
vkGetImageMemoryRequirements(device, image, &memReqs); | ||
|
||
uint32_t memoryTypeIndex | ||
= context.selectMemoryType(memReqs.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT); | ||
= context.selectMemoryType(memReqs.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | | ||
(isProtected ? VK_MEMORY_PROPERTY_PROTECTED_BIT : 0U)); | ||
|
||
FILAMENT_CHECK_POSTCONDITION(memoryTypeIndex < VK_MAX_MEMORY_TYPES) | ||
<< "VulkanPlatformSwapChainImpl: unable to find a memory type that meets requirements."; | ||
|
@@ -110,8 +112,8 @@ void VulkanPlatformSwapChainImpl::destroy() { | |
mSwapChainBundle.colors.clear(); | ||
} | ||
|
||
VkImage VulkanPlatformSwapChainImpl::createImage(VkExtent2D extent, VkFormat format) { | ||
auto [image, memory] = createImageAndMemory(mContext, mDevice, extent, format); | ||
VkImage VulkanPlatformSwapChainImpl::createImage(VkExtent2D extent, VkFormat format, bool isProtected) { | ||
auto [image, memory] = createImageAndMemory(mContext, mDevice, extent, format, isProtected); | ||
mMemory.insert({image, memory}); | ||
return image; | ||
} | ||
|
@@ -248,7 +250,7 @@ VkResult VulkanPlatformSurfaceSwapChain::create() { | |
mSwapChainBundle.colorFormat = surfaceFormat.format; | ||
mSwapChainBundle.depthFormat = | ||
selectDepthFormat(mContext.getAttachmentDepthStencilFormats(), mHasStencil); | ||
mSwapChainBundle.depth = createImage(mSwapChainBundle.extent, mSwapChainBundle.depthFormat); | ||
mSwapChainBundle.depth = createImage(mSwapChainBundle.extent, mSwapChainBundle.depthFormat, mIsProtected); | ||
mSwapChainBundle.isProtected = mIsProtected; | ||
|
||
FVK_LOGI << "vkCreateSwapchain" | ||
|
@@ -356,13 +358,14 @@ VulkanPlatformHeadlessSwapChain::VulkanPlatformHeadlessSwapChain(VulkanContext c | |
images.reserve(HEADLESS_SWAPCHAIN_SIZE); | ||
images.resize(HEADLESS_SWAPCHAIN_SIZE); | ||
for (size_t i = 0; i < HEADLESS_SWAPCHAIN_SIZE; ++i) { | ||
images[i] = createImage(extent, mSwapChainBundle.colorFormat); | ||
assert_invariant(mSwapChainBundle.isProtected == false); | ||
images[i] = createImage(extent, mSwapChainBundle.colorFormat, false); | ||
} | ||
|
||
bool const hasStencil = (flags & backend::SWAP_CHAIN_HAS_STENCIL_BUFFER) != 0; | ||
mSwapChainBundle.depthFormat = | ||
selectDepthFormat(mContext.getAttachmentDepthStencilFormats(), hasStencil); | ||
mSwapChainBundle.depth = createImage(extent, mSwapChainBundle.depthFormat); | ||
mSwapChainBundle.depth = createImage(extent, mSwapChainBundle.depthFormat, mSwapChainBundle.isProtected); | ||
} | ||
|
||
VulkanPlatformHeadlessSwapChain::~VulkanPlatformHeadlessSwapChain() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's remove this and also
mIsRenderPassProtected
andmIsContentProtected