Vulkan: Implement StoreOp::Discard
It wasn't implemented because Discard wasn't implemented for a long time. Bug: dawn:1151 Change-Id: Ie26559dd65a2c97a32df418521ca93c1021dd837 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/65720 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Brandon Jones <bajones@chromium.org>
This commit is contained in:
parent
bb417ace11
commit
bf8c40b4f1
|
@ -209,17 +209,18 @@ namespace dawn_native { namespace vulkan {
|
|||
const auto& attachmentInfo = renderPass->colorAttachments[i];
|
||||
|
||||
bool hasResolveTarget = attachmentInfo.resolveTarget != nullptr;
|
||||
wgpu::LoadOp loadOp = attachmentInfo.loadOp;
|
||||
|
||||
query.SetColor(i, attachmentInfo.view->GetFormat().format, loadOp,
|
||||
hasResolveTarget);
|
||||
query.SetColor(i, attachmentInfo.view->GetFormat().format,
|
||||
attachmentInfo.loadOp, attachmentInfo.storeOp, hasResolveTarget);
|
||||
}
|
||||
|
||||
if (renderPass->attachmentState->HasDepthStencilAttachment()) {
|
||||
const auto& attachmentInfo = renderPass->depthStencilAttachment;
|
||||
|
||||
query.SetDepthStencil(attachmentInfo.view->GetTexture()->GetFormat().format,
|
||||
attachmentInfo.depthLoadOp, attachmentInfo.stencilLoadOp);
|
||||
attachmentInfo.depthLoadOp, attachmentInfo.depthStoreOp,
|
||||
attachmentInfo.stencilLoadOp,
|
||||
attachmentInfo.stencilStoreOp);
|
||||
}
|
||||
|
||||
query.SetSampleCount(renderPass->attachmentState->GetSampleCount());
|
||||
|
|
|
@ -32,6 +32,16 @@ namespace dawn_native { namespace vulkan {
|
|||
}
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
VkAttachmentStoreOp VulkanAttachmentStoreOp(wgpu::StoreOp op) {
|
||||
switch (op) {
|
||||
case wgpu::StoreOp::Store:
|
||||
return VK_ATTACHMENT_STORE_OP_STORE;
|
||||
case wgpu::StoreOp::Discard:
|
||||
return VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||
}
|
||||
UNREACHABLE();
|
||||
}
|
||||
} // anonymous namespace
|
||||
|
||||
// RenderPassCacheQuery
|
||||
|
@ -39,20 +49,26 @@ namespace dawn_native { namespace vulkan {
|
|||
void RenderPassCacheQuery::SetColor(ColorAttachmentIndex index,
|
||||
wgpu::TextureFormat format,
|
||||
wgpu::LoadOp loadOp,
|
||||
wgpu::StoreOp storeOp,
|
||||
bool hasResolveTarget) {
|
||||
colorMask.set(index);
|
||||
colorFormats[index] = format;
|
||||
colorLoadOp[index] = loadOp;
|
||||
colorStoreOp[index] = storeOp;
|
||||
resolveTargetMask[index] = hasResolveTarget;
|
||||
}
|
||||
|
||||
void RenderPassCacheQuery::SetDepthStencil(wgpu::TextureFormat format,
|
||||
wgpu::LoadOp depthLoadOp,
|
||||
wgpu::LoadOp stencilLoadOp) {
|
||||
wgpu::LoadOp depthLoadOpIn,
|
||||
wgpu::StoreOp depthStoreOpIn,
|
||||
wgpu::LoadOp stencilLoadOpIn,
|
||||
wgpu::StoreOp stencilStoreOpIn) {
|
||||
hasDepthStencil = true;
|
||||
depthStencilFormat = format;
|
||||
this->depthLoadOp = depthLoadOp;
|
||||
this->stencilLoadOp = stencilLoadOp;
|
||||
depthLoadOp = depthLoadOpIn;
|
||||
depthStoreOp = depthStoreOpIn;
|
||||
stencilLoadOp = stencilLoadOpIn;
|
||||
stencilStoreOp = stencilStoreOpIn;
|
||||
}
|
||||
|
||||
void RenderPassCacheQuery::SetSampleCount(uint32_t sampleCount) {
|
||||
|
@ -113,7 +129,7 @@ namespace dawn_native { namespace vulkan {
|
|||
attachmentDesc.format = VulkanImageFormat(mDevice, query.colorFormats[i]);
|
||||
attachmentDesc.samples = vkSampleCount;
|
||||
attachmentDesc.loadOp = VulkanAttachmentLoadOp(query.colorLoadOp[i]);
|
||||
attachmentDesc.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
|
||||
attachmentDesc.storeOp = VulkanAttachmentStoreOp(query.colorStoreOp[i]);
|
||||
attachmentDesc.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||
attachmentDesc.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||
|
||||
|
@ -134,9 +150,9 @@ namespace dawn_native { namespace vulkan {
|
|||
attachmentDesc.format = VulkanImageFormat(mDevice, query.depthStencilFormat);
|
||||
attachmentDesc.samples = vkSampleCount;
|
||||
attachmentDesc.loadOp = VulkanAttachmentLoadOp(query.depthLoadOp);
|
||||
attachmentDesc.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
|
||||
attachmentDesc.storeOp = VulkanAttachmentStoreOp(query.depthStoreOp);
|
||||
attachmentDesc.stencilLoadOp = VulkanAttachmentLoadOp(query.stencilLoadOp);
|
||||
attachmentDesc.stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE;
|
||||
attachmentDesc.stencilStoreOp = VulkanAttachmentStoreOp(query.stencilStoreOp);
|
||||
attachmentDesc.initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
|
||||
attachmentDesc.finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
|
||||
|
||||
|
|
|
@ -41,21 +41,27 @@ namespace dawn_native { namespace vulkan {
|
|||
void SetColor(ColorAttachmentIndex index,
|
||||
wgpu::TextureFormat format,
|
||||
wgpu::LoadOp loadOp,
|
||||
wgpu::StoreOp storeOp,
|
||||
bool hasResolveTarget);
|
||||
void SetDepthStencil(wgpu::TextureFormat format,
|
||||
wgpu::LoadOp depthLoadOp,
|
||||
wgpu::LoadOp stencilLoadOp);
|
||||
wgpu::StoreOp depthStoreOp,
|
||||
wgpu::LoadOp stencilLoadOp,
|
||||
wgpu::StoreOp stencilStoreOp);
|
||||
void SetSampleCount(uint32_t sampleCount);
|
||||
|
||||
ityp::bitset<ColorAttachmentIndex, kMaxColorAttachments> colorMask;
|
||||
ityp::bitset<ColorAttachmentIndex, kMaxColorAttachments> resolveTargetMask;
|
||||
ityp::array<ColorAttachmentIndex, wgpu::TextureFormat, kMaxColorAttachments> colorFormats;
|
||||
ityp::array<ColorAttachmentIndex, wgpu::LoadOp, kMaxColorAttachments> colorLoadOp;
|
||||
ityp::array<ColorAttachmentIndex, wgpu::StoreOp, kMaxColorAttachments> colorStoreOp;
|
||||
|
||||
bool hasDepthStencil = false;
|
||||
wgpu::TextureFormat depthStencilFormat;
|
||||
wgpu::LoadOp depthLoadOp;
|
||||
wgpu::StoreOp depthStoreOp;
|
||||
wgpu::LoadOp stencilLoadOp;
|
||||
wgpu::StoreOp stencilStoreOp;
|
||||
|
||||
uint32_t sampleCount;
|
||||
};
|
||||
|
|
|
@ -496,19 +496,21 @@ namespace dawn_native { namespace vulkan {
|
|||
dynamic.dynamicStateCount = sizeof(dynamicStates) / sizeof(dynamicStates[0]);
|
||||
dynamic.pDynamicStates = dynamicStates;
|
||||
|
||||
// Get a VkRenderPass that matches the attachment formats for this pipeline, load ops don't
|
||||
// matter so set them all to LoadOp::Load
|
||||
// Get a VkRenderPass that matches the attachment formats for this pipeline, load/store ops
|
||||
// don't matter so set them all to LoadOp::Load / StoreOp::Store
|
||||
VkRenderPass renderPass = VK_NULL_HANDLE;
|
||||
{
|
||||
RenderPassCacheQuery query;
|
||||
|
||||
for (ColorAttachmentIndex i : IterateBitSet(GetColorAttachmentsMask())) {
|
||||
query.SetColor(i, GetColorAttachmentFormat(i), wgpu::LoadOp::Load, false);
|
||||
query.SetColor(i, GetColorAttachmentFormat(i), wgpu::LoadOp::Load,
|
||||
wgpu::StoreOp::Store, false);
|
||||
}
|
||||
|
||||
if (HasDepthStencilAttachment()) {
|
||||
query.SetDepthStencil(GetDepthStencilFormat(), wgpu::LoadOp::Load,
|
||||
wgpu::LoadOp::Load);
|
||||
wgpu::StoreOp::Store, wgpu::LoadOp::Load,
|
||||
wgpu::StoreOp::Store);
|
||||
}
|
||||
|
||||
query.SetSampleCount(GetSampleCount());
|
||||
|
|
|
@ -592,6 +592,10 @@ TEST_P(TextureZeroInitTest, IndependentDepthStencilLoadAfterDiscard) {
|
|||
// on some Intel drivers.
|
||||
DAWN_SUPPRESS_TEST_IF(IsMetal() && IsIntel());
|
||||
|
||||
// TODO(crbug.com/dawn/1151): The test started failing on Wintel Vulkan when Discard was
|
||||
// implemented for the Vulkan backend.
|
||||
DAWN_SUPPRESS_TEST_IF(IsVulkan() && IsWindows() && IsIntel());
|
||||
|
||||
wgpu::TextureDescriptor depthStencilDescriptor = CreateTextureDescriptor(
|
||||
1, 1, wgpu::TextureUsage::RenderAttachment | wgpu::TextureUsage::CopySrc,
|
||||
kDepthStencilFormat);
|
||||
|
|
Loading…
Reference in New Issue