Metal: Fix rendering to a layer of a depth/stencil texture

Bug: dawn:430
Change-Id: Ice053a44a0720055fe02b2589153a04ffaa87e65
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/22302
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
This commit is contained in:
Austin Eng 2020-05-28 08:51:23 +00:00 committed by Commit Bot service account
parent bf3611ce73
commit 09987b88f1
3 changed files with 7 additions and 5 deletions

View File

@ -939,11 +939,9 @@ namespace dawn_native { namespace d3d12 {
}
D3D12_DEPTH_STENCIL_VIEW_DESC TextureView::GetDSVDescriptor() const {
// TODO(jiawei.shao@intel.com): support rendering into a layer of a texture.
ASSERT(GetLevelCount() == 1);
uint32_t mipLevel = GetBaseMipLevel();
return ToBackend(GetTexture())
->GetDSVDescriptor(mipLevel, GetBaseArrayLayer(), GetLayerCount());
->GetDSVDescriptor(GetBaseMipLevel(), GetBaseArrayLayer(), GetLayerCount());
}
D3D12_UNORDERED_ACCESS_VIEW_DESC TextureView::GetUAVDescriptor() const {

View File

@ -102,13 +102,14 @@ namespace dawn_native { namespace metal {
if (renderPass->attachmentState->HasDepthStencilAttachment()) {
auto& attachmentInfo = renderPass->depthStencilAttachment;
// TODO(jiawei.shao@intel.com): support rendering into a layer of a texture.
id<MTLTexture> texture =
ToBackend(attachmentInfo.view->GetTexture())->GetMTLTexture();
const Format& format = attachmentInfo.view->GetTexture()->GetFormat();
if (format.HasDepth()) {
descriptor.depthAttachment.texture = texture;
descriptor.depthAttachment.level = attachmentInfo.view->GetBaseMipLevel();
descriptor.depthAttachment.slice = attachmentInfo.view->GetBaseArrayLayer();
switch (attachmentInfo.depthStoreOp) {
case wgpu::StoreOp::Store:
@ -142,6 +143,8 @@ namespace dawn_native { namespace metal {
if (format.HasStencil()) {
descriptor.stencilAttachment.texture = texture;
descriptor.stencilAttachment.level = attachmentInfo.view->GetBaseMipLevel();
descriptor.stencilAttachment.slice = attachmentInfo.view->GetBaseArrayLayer();
switch (attachmentInfo.stencilStoreOp) {
case wgpu::StoreOp::Store:

View File

@ -155,8 +155,9 @@ TEST_P(SubresourceOutputAttachmentTest, DISABLED_StencilTexture) {
DoTest(Type::Stencil);
}
// TODO(crbug.com/dawn/430): Implemented incorrectly on OpenGL and Metal.
// TODO(crbug.com/dawn/430): Not implemented on OpenGL
DAWN_INSTANTIATE_TEST(SubresourceOutputAttachmentTest,
D3D12Backend(),
D3D12Backend({}, {"use_d3d12_render_pass"}),
MetalBackend(),
VulkanBackend());