Skip to content

Add mipmap support to createTextureWithData.#1332

Open
manon-traverse wants to merge 2 commits into
llvm:mainfrom
Traverse-Research:create-texture-with-data-upload-mips
Open

Add mipmap support to createTextureWithData.#1332
manon-traverse wants to merge 2 commits into
llvm:mainfrom
Traverse-Research:create-texture-with-data-upload-mips

Conversation

@manon-traverse

@manon-traverse manon-traverse commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

createTextureWithData now also uploads mipmap when creating a texture.

This required introducing a new function to query the texture footprint, as well as adding support for copying mips to the copyBufferToTexture function.

Resolves #1039

@manon-traverse manon-traverse force-pushed the create-texture-with-data-upload-mips branch from 4eafcd6 to 35cadc0 Compare June 30, 2026 14:11
@manon-traverse manon-traverse marked this pull request as ready for review June 30, 2026 14:11

@MarijnS95 MarijnS95 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with a few nits inline. Mip math is consistent across backends and the new seam is clean.

# Unimplemented: Clang + DX: https://github.com/llvm/llvm-project/issues/101558
# XFAIL: DirectX || Metal
# Unimplemented: Metal: https://github.com/llvm/llvm-project/issues/101558
# XFAIL: Metal

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This re-points the same issue (llvm-project#101558) from "Clang + DX" to "Metal". If it's a clang frontend issue it should hit DX and Metal equally, so DX presumably now passes for a different reason (the MipLevels propagation) and the link was mis-attributed. Can you confirm DX CI is green here and fix the comment's rationale rather than re-aiming the same link at Metal?

Comment thread lib/API/DX/Device.cpp
Comment thread lib/API/Texture.cpp
const uint32_t MipHeight = std::max(1u, Desc.Height >> I);
SubresourceFootprint Sub;
Sub.Offset = Offset;
Sub.RowSizeInBytes = MipWidth * ElementSize;

@MarijnS95 MarijnS95 Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assumes uncompressed formats: MipWidth * ElementSize and mips shrinking to 1x1 texel are wrong for block-compressed formats (min 4x4 block). DX is fine via GetCopyableFootprints; VK/Metal would not be. No BC formats in the suite today, so just worth a note:

Suggested change
Sub.RowSizeInBytes = MipWidth * ElementSize;
// Assumes uncompressed formats; block-compressed formats would need
// block-based row sizing rather than MipWidth * ElementSize.
Sub.RowSizeInBytes = MipWidth * ElementSize;

@MarijnS95

Copy link
Copy Markdown
Collaborator

Is this now a duplicate of #1230, which we can subsequently close as fixed?

@EmilioLaiso EmilioLaiso left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[DirectX] Add multiple mip level support

4 participants