Skip to content

Commit

Permalink
vk: fix dynamic scissor validation error (#7853)
Browse files Browse the repository at this point in the history
  • Loading branch information
poweifeng committed May 14, 2024
1 parent 85eb724 commit 7267696
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
8 changes: 7 additions & 1 deletion filament/backend/src/vulkan/VulkanDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1873,6 +1873,12 @@ void VulkanDriver::bindPipeline(PipelineState pipelineState) {

mPipelineCache.bindLayout(pipelineLayout);
mPipelineCache.bindPipeline(commands);

// Since we don't statically define scissor as part of the pipeline, we need to call scissor at
// least once. Context: VUID-vkCmdDrawIndexed-None-07832.
auto const& extent = rt->getExtent();
scissor({0, 0, extent.width, extent.height});

FVK_SYSTRACE_END();
}

Expand Down Expand Up @@ -1963,7 +1969,7 @@ void VulkanDriver::scissor(Viewport scissorBox) {

const VulkanRenderTarget* rt = mCurrentRenderPass.renderTarget;
rt->transformClientRectToPlatform(&scissor);
mPipelineCache.bindScissor(cmdbuffer, scissor);
vkCmdSetScissor(cmdbuffer, 0, 1, &scissor);
}

void VulkanDriver::beginTimerQuery(Handle<HwTimerQuery> tqh) {
Expand Down
5 changes: 0 additions & 5 deletions filament/backend/src/vulkan/VulkanPipelineCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@ void VulkanPipelineCache::bindPipeline(VulkanCommandBuffer* commands) {
commands->setPipeline(cacheEntry->handle);
}

void VulkanPipelineCache::bindScissor(VkCommandBuffer cmdbuffer, VkRect2D scissor) noexcept {
vkCmdSetScissor(cmdbuffer, 0, 1, &scissor);
}

VulkanPipelineCache::PipelineCacheEntry* VulkanPipelineCache::createPipeline() noexcept {
assert_invariant(mPipelineRequirements.shaders[0] && "Vertex shader is not bound.");
assert_invariant(mPipelineRequirements.layout && "No pipeline layout specified");
Expand Down Expand Up @@ -306,7 +302,6 @@ void VulkanPipelineCache::gc() noexcept {
// The Vulkan spec says: "When a command buffer begins recording, all state in that command
// buffer is undefined." Therefore, we need to clear all bindings at this time.
mBoundPipeline = {};
mCurrentScissor = {};

// NOTE: Due to robin_map restrictions, we cannot use auto or range-based loops.

Expand Down
6 changes: 0 additions & 6 deletions filament/backend/src/vulkan/VulkanPipelineCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,6 @@ class VulkanPipelineCache {
// Creates a new pipeline if necessary and binds it using vkCmdBindPipeline.
void bindPipeline(VulkanCommandBuffer* commands);

// Sets up a new scissor rectangle if it has been dirtied.
void bindScissor(VkCommandBuffer cmdbuffer, VkRect2D scissor) noexcept;

// Each of the following methods are fast and do not make Vulkan calls.
void bindProgram(VulkanProgram* program) noexcept;
void bindRasterState(const RasterState& rasterState) noexcept;
Expand Down Expand Up @@ -263,9 +260,6 @@ class VulkanPipelineCache {

// Current bindings for the pipeline and descriptor sets.
PipelineKey mBoundPipeline = {};

// Current state for scissoring.
VkRect2D mCurrentScissor = {};
};

} // namespace filament::backend
Expand Down

0 comments on commit 7267696

Please sign in to comment.