Skip to content

Register DxilCounters.cpp with hctgen and regenerate#10

Draft
Copilot wants to merge 8 commits intomainfrom
copilot/fix-issue-8293
Draft

Register DxilCounters.cpp with hctgen and regenerate#10
Copilot wants to merge 8 commits intomainfrom
copilot/fix-issue-8293

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 25, 2026

lib/DXIL/DxilCounters.cpp contains <py> code tags driven by the DXIL instruction database, but was never registered with add_hlsl_hctgen(). As a result it was never regenerated when HLSL_COPY_GENERATED_SOURCES was set, causing it to silently drift out of sync as new opcodes were added.

Changes

  • cmake/modules/HCT.cmakeadd_hlsl_hctgen() now automatically derives the CMake target name as ${mode}_${extension} (e.g. DxilCounters_h, DxilCounters_cpp). This ensures target names are unique even when the same hctgen mode generates both a .h and a .cpp file, without requiring any caller-visible special-casing. The one existing external reference to a target by name (DxilIntrinsicTables) is updated to DxilIntrinsicTables_h in tools/clang/lib/Sema/CMakeLists.txt.

  • lib/DXIL/CMakeLists.txt — Registers DxilCounters.cpp with the codegen pipeline:

    add_hlsl_hctgen(DxilCounters OUTPUT DxilCounters.cpp CODE_TAG)
  • lib/DXIL/DxilCounters.cpp — Regenerated. Previously-missing opcodes now covered:

    Counter Added opcodes
    barrier BarrierByMemoryType, BarrierByMemoryHandle, BarrierByNodeRecordHandle
    floats FDot
    ints / uints VectorReduceAnd, VectorReduceOr
    tex_cmp SampleCmpGrad, SampleCmpBias
    tex_load RawBufferVectorLoad
    tex_store RawBufferVectorStore

⌨️ Start Copilot coding agent tasks without leaving your editor — available in VS Code, Visual Studio, JetBrains IDEs and Eclipse.

- Add TARGET_NAME optional parameter to add_hlsl_hctgen() in HCT.cmake
  to allow different CMake target name and hctgen mode (needed since
  DxilCounters is already used as the target name for DxilCounters.h)
- Add add_hlsl_hctgen(DxilCounters OUTPUT DxilCounters.cpp CODE_TAG ...)
  to lib/DXIL/CMakeLists.txt so DxilCounters.cpp participates in source
  regeneration when HLSL_COPY_GENERATED_SOURCES is set
- Regenerate DxilCounters.cpp: adds BarrierByMemoryType/Handle/Node,
  FDot, VectorReduceAnd/Or, SampleCmpGrad/Bias, RawBufferVectorLoad/Store

Co-authored-by: damyanp <8118402+damyanp@users.noreply.github.com>
Agent-Logs-Url: https://github.com/damyanp/DirectXShaderCompiler/sessions/12071741-931b-464e-90a5-ce03c9b6e9c3
Comment thread lib/DXIL/CMakeLists.txt Outdated
# This file is distributed under the University of Illinois Open Source License.
# See LICENSE.TXT for details.

add_hlsl_hctgen(DxilCounters OUTPUT DxilCounters.cpp CODE_TAG TARGET_NAME DxilCountersCpp)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@copilot what is special about DxilCounters.cpp that means it needs a special TARGET_NAME parameter? None of the ones below seem to need this.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The first argument to add_hlsl_hctgen serves double duty: it's both the hctgen generation mode (passed directly to hctgen.py) and the CMake target name. DxilCounters is the only hctgen mode that generates two separate files — DxilCounters.h (in include/dxc/DXIL/CMakeLists.txt) and DxilCounters.cpp (in lib/DXIL/CMakeLists.txt). Since both calls must pass DxilCounters as the mode, but CMake target names must be unique, one of them needs a different target name.

I tried renaming the mode to DxilCountersH for the .h side, but that breaks hctgen.py which only accepts fixed mode names. TARGET_NAME is the minimal way to decouple the CMake target name from the hctgen mode.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@copilot I'm convinced that this is truly a special case. Is the target name actually important and relied upon anywhere? If not, then how about the output file extension is always added to the target name?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The target names were not relied upon by name externally, with one exception: DxilIntrinsicTables in tools/clang/lib/Sema/CMakeLists.txt.

Implemented your suggestion in ddcbecf: the TARGET_NAME parameter is removed and the target name is now always auto-derived as ${mode}_${extension} (e.g. DxilCounters_h, DxilCounters_cpp). Updated the one external reference accordingly (DxilIntrinsicTablesDxilIntrinsicTables_h).

Instead of a special-purpose TARGET_NAME parameter, the CMake target name
is now automatically derived as "${mode}_${extension}" (e.g. DxilCounters_h,
DxilCounters_cpp). This resolves the DxilCounters name conflict between the
.h and .cpp targets without any caller-visible special-casing.

Update the one external reference (DxilIntrinsicTables →
DxilIntrinsicTables_h) in tools/clang/lib/Sema/CMakeLists.txt.

Co-authored-by: damyanp <8118402+damyanp@users.noreply.github.com>
Agent-Logs-Url: https://github.com/damyanp/DirectXShaderCompiler/sessions/9de1b168-12bd-407d-b2e7-e83f2480dc9d
Keenuts and others added 6 commits March 26, 2026 09:36
This commit fixes 2 warnings showing on when building on MacOS:
 - CMP0135: setting which policy is applied on download freshness check
 - METAL_IRCONVERTER case not matching the FindPackage filename.
)

Update `DxilStructAnnotation` to be aware of target types. Otherwise the annotation would declare a struct with a single LinAlg Matrix type as empty, leading to invalid codegen.

Declaration names match the style of the surrounding code. 

Fixes microsoft#8279
Addresses outstanding cleanup requests from the initial LinAlg exec test
PR

---------

Co-authored-by: Damyan Pepper <damyanp@microsoft.com>
Updates the SPIR-V dependencies, and update an invalid test.
The experimental Cooperative Vector feature has been superseded by
LinAlg. This change removes the code supporting the old feature.

Fixes microsoft#8147

---------

Co-authored-by: Helena Kotas <hekotas@microsoft.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: damyanp <8118402+damyanp@users.noreply.github.com>
damyanp pushed a commit that referenced this pull request Mar 28, 2026
…unction overloads. (microsoft#8287)

Part of microsoft#7979

Restructured to test each function overloads.
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.

6 participants