Skip to content

[Vulkan][DirectX] Refactor texture handling in anticipation of other texture types - #1465

Open
Icohedron wants to merge 1 commit into
mainfrom
users/icohedron/texture-refactor
Open

[Vulkan][DirectX] Refactor texture handling in anticipation of other texture types#1465
Icohedron wants to merge 1 commit into
mainfrom
users/icohedron/texture-refactor

Conversation

@Icohedron

@Icohedron Icohedron commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

A new TextureDimension enum has been added. Places where a 2D texture-related were expected are now replaced with a helper function and switch over the enum to return the appropriate value.

Places that assumed the number of texture subresources was the number of mip levels are now replaced with a call to a helper to obtain the correct subresource count. The number of subresources is equal to the number of mip levels right now, but that will change with array textures which will add array slices.

Added backend-agnostic helper functions for texture subresource layout arithmetic, and symmetric functions for copying texture contents between tightly-packed host buffers and GPU-mapped memory regions.

Also fixes two latent bugs:
DX copyTextureToBuffer only copied subresource 0, never reading back mip beyond the most detailed one (mip 0).
VK copyTextureToBuffer passed regionCount = 0, making the copy a no-op.

Assisted by: Claude Opus 5


Stack created with GitHub Stacks CLIGive Feedback 💬

@Icohedron Icohedron changed the title Refactor texture handling in anticipation of other texture types [Vulkan][DirectX] Refactor texture handling in anticipation of other texture types Aug 20, 2026
A new TextureDimension enum has been added. Places where a 2D
texture-related were expected are now replaced with a helper function
and switch over the enum to return the appropriate value.

Places that assumed the number of texture subresources was the number of
mip levels are now replaced with a call to a helper to obtain the
correct subresource count. The number of subresources is equal to the
number of mip levels right now, but that will change with array textures
which will add array slices.

Added backend-agnostic helper functions for texture subresource layout
arithmetic, and symmetric functions for copying texture contents between
tightly-packed host buffers and GPU-mapped memory regions.

Also fixes two latent bugs:
DX copyTextureToBuffer only copied subresource 0, never reading back mip
beyond the most detailed one (mip 0).
VK copyTextureToBuffer passed regionCount = 0, making the copy a no-op.

Assisted by: Claude Opus 5
@Icohedron
Icohedron force-pushed the users/icohedron/texture-refactor branch from 7d63059 to 28f82c4 Compare August 21, 2026 02:33
Comment thread include/API/Texture.h
Comment thread include/API/Texture.h

// Copy a texture's contents between a tightly-packed host buffer and a
// (possibly row/subresource padded) GPU-visible mapping described by `Layout`.
// These are the single place that knows how to bridge the two layouts, so

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: comment grammar

Comment thread lib/API/DX/Device.cpp

@bob80905 bob80905 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

only outstanding thing is grammar inside a comment, LGTM

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.

2 participants