Skip to content

[SPIR-V][vk::SampledTexture] #8. Support vk::SampledTexture2DArray type. #8188

Merged
s-perron merged 2 commits intomicrosoft:mainfrom
luciechoi:texture2darray
Mar 4, 2026
Merged

[SPIR-V][vk::SampledTexture] #8. Support vk::SampledTexture2DArray type. #8188
s-perron merged 2 commits intomicrosoft:mainfrom
luciechoi:texture2darray

Conversation

@luciechoi
Copy link
Collaborator

Part of #7979

vk::SampledTexture2DArray takes coordinate of vector size 3.

The function definitions are equivalent to that of Texture2DArray, just without Sampler argument.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the Vulkan vk::SampledTexture support in the SPIR-V path by adding the vk::SampledTexture2DArray object type (with 3-component coordinates) and wiring it through semantic analysis, type lowering, and SPIR-V emission, along with new/updated CodeGenSPIRV tests.

Changes:

  • Add vk::SampledTexture2DArray as a legal intrinsic/object type and expose its method set in the HCT database.
  • Update SPIR-V type lowering and codegen to recognize sampled-texture objects (including array form) for sampling/gathering and indexing (operator[] / .mips[]).
  • Add and update CodeGenSPIRV tests to validate sampling, gather, load, dimensions, and indexing for vk::SampledTexture2D and vk::SampledTexture2DArray.

Reviewed changes

Copilot reviewed 41 out of 41 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
utils/hct/hctdb.py Allow VkSampledTexture2DArray in the intrinsic object-type matcher.
utils/hct/gen_intrin_main.txt Define method sets for VkSampledTexture2D (expanded) and new VkSampledTexture2DArray.
include/dxc/dxcapi.internal.h Add LICOMPTYPE_VK_SAMPLED_TEXTURE2D_ARRAY enum entry and bump count.
tools/clang/lib/Sema/SemaHLSL.cpp Add basic kind/type plumbing, resource-kind mapping, and method dispatch for SampledTexture2DArray.
tools/clang/lib/SPIRV/AstTypeProbe.cpp Treat vk::SampledTexture2DArray as a sampled texture for SPIR-V codegen decisions.
tools/clang/lib/SPIRV/LowerTypeVisitor.cpp Lower vk::SampledTexture2DArray to an arrayed 2D sampled image type.
tools/clang/lib/SPIRV/SpirvEmitter.cpp Extend sampling/gather/indexing paths to work with sampled-texture objects and optional arg parsing.
tools/clang/lib/AST/ASTContextHLSL.cpp Remove now-stale TODO comment about only supporting SampledTexture2D.
tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample.hlsl Update/extend sample coverage to include SampledTexture2DArray.
tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather.hlsl Update/extend gather coverage to include SampledTexture2DArray.
tools/clang/test/CodeGenSPIRV/vk.sampledtexture.load.hlsl Extend load coverage to include SampledTexture2DArray.
tools/clang/test/CodeGenSPIRV/vk.sampledtexture.get-dimensions.hlsl Extend GetDimensions coverage to include array elements/levels for sampled textures.
tools/clang/test/CodeGenSPIRV/vk.sampledtexture.calculate-lod.hlsl Add CalculateLevelOfDetail coverage for SampledTexture2DArray.
tools/clang/test/CodeGenSPIRV/vk.sampledtexture.calculate-lod-unclamped.hlsl Add CalculateLevelOfDetailUnclamped coverage for SampledTexture2DArray.
tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-level.hlsl New: SampleLevel coverage (2D + array).
tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-grad.hlsl New: SampleGrad coverage (2D + array).
tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-cmp.hlsl New: SampleCmp coverage (2D + array).
tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-cmp-level-zero.hlsl New: SampleCmpLevelZero coverage (2D + array).
tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-cmp-grad.hlsl New: SampleCmpGrad coverage.
tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-cmp-bias.hlsl New: SampleCmpBias coverage.
tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-bias.hlsl New: SampleBias coverage (2D + array).
tools/clang/test/CodeGenSPIRV/vk.sampledtexture.cmp-level.hlsl New: SampleCmpLevel coverage (2D + array).
tools/clang/test/CodeGenSPIRV/vk.sampledtexture.access.hlsl New: operator[] coverage for sampled textures (2D + array).
tools/clang/test/CodeGenSPIRV/vk.sampledtexture.mips-access.hlsl New: .mips[] indexing coverage for sampled textures (2D + array).
tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather-red.hlsl New: GatherRed coverage (2D + array).
tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather-green.hlsl New: GatherGreen coverage (2D + array).
tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather-blue.hlsl New: GatherBlue coverage (2D + array).
tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather-alpha.hlsl New: GatherAlpha coverage (2D + array).
tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather-cmp.hlsl New: GatherCmp coverage (2D + array).
tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather-cmp-red.hlsl New: GatherCmpRed coverage (2D + array).
tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather-cmp-green.hlsl New: negative test for Vulkan-missing GatherCmpGreen.
tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather-cmp-blue.hlsl New: negative test for Vulkan-missing GatherCmpBlue.
tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather-cmp-alpha.hlsl New: negative test for Vulkan-missing GatherCmpAlpha.
tools/clang/test/CodeGenSPIRV/texture.sample.hlsl Adjust CHECK ordering for clamp load vs image/sampler load.
tools/clang/test/CodeGenSPIRV/texture.sample-grad.hlsl Adjust CHECK ordering for clamp load vs image/sampler load.
tools/clang/test/CodeGenSPIRV/texture.sample-cmp.hlsl Adjust CHECK ordering for clamp load vs image/sampler/comparator load.
tools/clang/test/CodeGenSPIRV/texture.sample-bias.hlsl Adjust CHECK ordering for clamp load vs image/sampler load.
tools/clang/test/CodeGenSPIRV/texture.array.sample.hlsl Adjust CHECK ordering for clamp load vs image/sampler load.
tools/clang/test/CodeGenSPIRV/texture.array.sample-grad.hlsl Adjust CHECK ordering for clamp load vs image/sampler load.
tools/clang/test/CodeGenSPIRV/texture.array.sample-cmp.hlsl Adjust CHECK ordering for clamp load vs image/sampler/comparator load.
tools/clang/test/CodeGenSPIRV/texture.array.sample-bias.hlsl Adjust CHECK ordering for clamp load vs image/sampler load.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 30 out of 30 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@s-perron
Copy link
Collaborator

s-perron commented Mar 4, 2026

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@luciechoi
Copy link
Collaborator Author

(also updated all the PRs to wrap the texture type under #ifdef CODEGEN_SPIRV)

@s-perron s-perron enabled auto-merge (squash) March 4, 2026 20:19
@s-perron
Copy link
Collaborator

s-perron commented Mar 4, 2026

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@s-perron s-perron merged commit 1f63535 into microsoft:main Mar 4, 2026
12 checks passed
@github-project-automation github-project-automation bot moved this from New to Done in HLSL Roadmap Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants