Skip to content

Commit

Permalink
Merge branch 'main' into coop_matrix2
Browse files Browse the repository at this point in the history
  • Loading branch information
s-perron committed Sep 12, 2024
2 parents 7da6d72 + f11914c commit 285a04c
Show file tree
Hide file tree
Showing 98 changed files with 4,039 additions and 691 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ release mode for DXIL 1.1 and Shader Model 6.1 (View Instancing support only).

Drivers can be downloaded from the following link [Intel Graphics Drivers](https://downloadcenter.intel.com/product/80939/Graphics-Drivers)

Direct access to 15.60 driver (latest as of of this update) is provided below:
Direct access to 15.60 driver (latest as of this update) is provided below:

[Installer](https://downloadmirror.intel.com/27412/a08/win64_15.60.2.4901.exe)

Expand Down
11 changes: 8 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ stages:
Linux_Clang_Release:
image: ${{ variables.linux }}
configuration: Release
CC: clang
CXX: clang++
CC: clang-18
CXX: clang++-18
CMAKE_OPTS: -DLLVM_ENABLE_WERROR=On -DLLVM_USE_SANITIZER='Address;Undefined' -DLLVM_ENABLE_LIBCXX=On -DLLVM_USE_LINKER=lld
CHECK_ALL_ENV: ASAN_OPTIONS=alloc_dealloc_mismatch=0
OS: Linux
Expand Down Expand Up @@ -98,7 +98,12 @@ stages:
inputs:
versionSpec: '3.x'

- bash: sudo apt-get install ninja-build
- bash: |
sudo apt-get install ninja-build
wget https://apt.llvm.org/llvm.sh
chmod u+x llvm.sh
sudo ./llvm.sh 18
sudo apt-get install libc++-18-dev
displayName: 'Installing dependencies'
condition: eq(variables['image'], variables['linux'])
Expand Down
43 changes: 37 additions & 6 deletions docs/SPIR-V.rst
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,8 @@ interface variables:
main([[vk::location(N)]] float4 input: A) : B
{ ... }
Macro for SPIR-V
----------------
Macros for SPIR-V
-----------------

If SPIR-V CodeGen is enabled and ``-spirv`` flag is used as one of the command
line options (meaning that "generates SPIR-V code"), it defines an implicit
Expand All @@ -412,6 +412,12 @@ specific part of the HLSL code:
#endif
RWStructuredBuffer<S> mySBuffer;
When the ``-spirv`` flag is used, the ``-fspv-target-env`` option will
implicitly define the macros ``__SPIRV_MAJOR_VERSION__`` and
``__SPIRV_MINOR_VERSION__``, which will be integers representing the major and
minor version of the SPIR-V being generated. This can be used to enable code that uses a feature
only for environments where that feature is available.

SPIR-V version and extension
----------------------------

Expand Down Expand Up @@ -2884,6 +2890,30 @@ If an output unsigned integer ``status`` argument is present,
``OpImageSparseSampleDrefExplicitLod`` is used instead. The resulting SPIR-V
``Residency Code`` will be written to ``status``.

``.SampleCmpBias(sampler, location, bias, comparator[, offset][, clamp][, Status])``
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Not available to ``Texture3D``, ``Texture2DMS``, and ``Texture2DMSArray``.

The translation is similar to ``.SampleBias()``, but the
``OpImageSampleDrefImplicitLod`` instruction is used.

If an output unsigned integer ``status`` argument is present,
``OpImageSparseSampleDrefImplicitLod`` is used instead. The resulting SPIR-V
``Residency Code`` will be written to ``status``.

``.SampleCmpGrad(sampler, location, ddx, ddy, comparator[, offset][, clamp][, Status])``
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Not available to ``Texture3D``, ``Texture2DMS``, and ``Texture2DMSArray``.

The translation is similar to ``.SampleGrad()``, but the
``OpImageSampleDrefExplicitLod`` instruction are used.

If an output unsigned integer ``status`` argument is present,
``OpImageSparseSampleDrefExplicitLod`` is used instead. The resulting SPIR-V
``Residency Code`` will be written to ``status``.

``.Gather()``
+++++++++++++

Expand Down Expand Up @@ -2977,10 +3007,11 @@ Not available to ``Texture2DMS`` and ``Texture2DMSArray``.

Since texture types are represented as ``OpTypeImage``, the ``OpImageQueryLod``
instruction is used for translation. An ``OpSampledImage`` is created based on
the ``SamplerState`` passed to the function. The resulting sampled image and
the coordinate passed to the function are used to invoke ``OpImageQueryLod``.
The result of ``OpImageQueryLod`` is a ``float2``. The first element contains
the mipmap array layer. The second element contains the unclamped level of detail.
the ``SamplerState`` or ``SamplerComparisonState`` passed to the function. The
resulting sampled image and the coordinate passed to the function are used to
invoke ``OpImageQueryLod``. The result of ``OpImageQueryLod`` is a ``float2``.
The first element contains the mipmap array layer. The second element contains
the unclamped level of detail.

``Texture1D``
~~~~~~~~~~~~~
Expand Down
6 changes: 6 additions & 0 deletions include/dxc/DxilContainer/DxilContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ enum class DxilProgramSigSemantic : uint32_t {
InnerCoverage = 70,
};

DxilProgramSigSemantic SemanticKindToSystemValue(DXIL::SemanticKind,
DXIL::TessellatorDomain);

enum class DxilProgramSigCompType : uint32_t {
Unknown = 0,
UInt32 = 1,
Expand All @@ -179,6 +182,9 @@ enum class DxilProgramSigCompType : uint32_t {
Float64 = 9,
};

DxilProgramSigCompType CompTypeToSigCompType(DXIL::ComponentType,
bool i1ToUnknownCompat);

struct DxilProgramSignatureElement {
uint32_t Stream; // Stream index (parameters must appear in non-decreasing
// stream order)
Expand Down
44 changes: 42 additions & 2 deletions include/dxc/DxilContainer/DxilPipelineStateValidation.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@
#define __DXIL_PIPELINE_STATE_VALIDATION__H__

#include "dxc/WinAdapter.h"
#include <assert.h>
#include <cstring>
#include <stdint.h>

namespace llvm {
class raw_ostream;
}

// Don't include assert.h here.
// Since this header is included from multiple environments,
// it is necessary to define assert before this header is included.
Expand Down Expand Up @@ -229,11 +234,13 @@ struct PSVResourceBindInfo0 {
uint32_t Space;
uint32_t LowerBound;
uint32_t UpperBound;
void Print(llvm::raw_ostream &O) const;
};

struct PSVResourceBindInfo1 : public PSVResourceBindInfo0 {
uint32_t ResKind; // PSVResourceKind
uint32_t ResFlags; // special characteristics of the resource
void Print(llvm::raw_ostream &O) const;
};

// Helpers for output dependencies (ViewID and Input-Output tables)
Expand Down Expand Up @@ -266,7 +273,8 @@ struct PSVComponentMask {
if (ComponentIndex < NumVectors * 4)
Mask[ComponentIndex >> 5] &= ~(1 << (ComponentIndex & 0x1F));
}
bool IsValid() { return Mask != nullptr; }
bool IsValid() const { return Mask != nullptr; }
void Print(llvm::raw_ostream &, const char *, const char *) const;
};

struct PSVDependencyTable {
Expand All @@ -282,14 +290,23 @@ struct PSVDependencyTable {
: Table(pTable), InputVectors(inputVectors),
OutputVectors(outputVectors) {}
PSVComponentMask GetMaskForInput(uint32_t inputComponentIndex) {
return getMaskForInput(inputComponentIndex);
}
const PSVComponentMask GetMaskForInput(uint32_t inputComponentIndex) const {
return getMaskForInput(inputComponentIndex);
}
bool IsValid() const { return Table != nullptr; }
void Print(llvm::raw_ostream &, const char *, const char *) const;

private:
PSVComponentMask getMaskForInput(uint32_t inputComponentIndex) const {
if (!Table || !InputVectors || !OutputVectors)
return PSVComponentMask();
return PSVComponentMask(
Table + (PSVComputeMaskDwordsFromVectors(OutputVectors) *
inputComponentIndex),
OutputVectors);
}
bool IsValid() { return Table != nullptr; }
};

struct PSVString {
Expand Down Expand Up @@ -431,6 +448,7 @@ class PSVSignatureElement {
uint32_t GetDynamicIndexMask() const {
return !m_pElement0 ? 0 : (uint32_t)m_pElement0->DynamicMaskAndStream & 0xF;
}
void Print(llvm::raw_ostream &O) const;
};

#define MAX_PSV_VERSION 3
Expand Down Expand Up @@ -732,6 +750,9 @@ class DxilPipelineStateValidation {
? m_StringTable.Get(m_pPSVRuntimeInfo3->EntryFunctionName)
: "";
}
void PrintPSVRuntimeInfo(llvm::raw_ostream &O, uint8_t ShaderKind,
const char *Comment) const;
void Print(llvm::raw_ostream &O, uint8_t ShaderKind) const;
};

// Return true if size fits in remaing buffer.
Expand Down Expand Up @@ -1036,6 +1057,10 @@ DxilPipelineStateValidation::ReadOrWrite(const void *pBits, uint32_t *pSize,

namespace hlsl {

class DxilResourceBase;
class DxilSignatureElement;
class DxilModule;

class ViewIDValidator {
public:
enum class Result {
Expand All @@ -1059,6 +1084,21 @@ class ViewIDValidator {
ViewIDValidator *NewViewIDValidator(unsigned viewIDCount,
unsigned gsRastStreamIndex);

void InitPSVResourceBinding(PSVResourceBindInfo0 *, PSVResourceBindInfo1 *,
DxilResourceBase *);

// Setup PSVSignatureElement0 with DxilSignatureElement.
// Note that the SemanticName and SemanticIndexes are not done.
void InitPSVSignatureElement(PSVSignatureElement0 &E,
const DxilSignatureElement &SE,
bool i1ToUnknownCompat);

// Setup PSVRuntimeInfo* with DxilModule.
// Note that the EntryFunctionName is not done.
void InitPSVRuntimeInfo(PSVRuntimeInfo0 *pInfo, PSVRuntimeInfo1 *pInfo1,
PSVRuntimeInfo2 *pInfo2, PSVRuntimeInfo3 *pInfo3,
const DxilModule &DM);

} // namespace hlsl

#undef PSV_RETB
Expand Down
4 changes: 2 additions & 2 deletions include/dxc/Support/HLSLOptions.td
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,8 @@ def fvk_use_dx_position_w: Flag<["-"], "fvk-use-dx-position-w">, Group<spirv_Gro
HelpText<"Reciprocate SV_Position.w after reading from stage input in PS to accommodate the difference between Vulkan and DirectX">;
def fvk_support_nonzero_base_instance: Flag<["-"], "fvk-support-nonzero-base-instance">, Group<spirv_Group>, Flags<[CoreOption, DriverOption]>,
HelpText<"Follow Vulkan spec to use gl_BaseInstance as the first vertex instance, which makes SV_InstanceID = gl_InstanceIndex - gl_BaseInstance (without this option, SV_InstanceID = gl_InstanceIndex)">;
def fvk_support_nonzero_base_vertex: Flag<["-"], "fvk-support-nonzero-base-vertex">, Group<spirv_Group>, Flags<[CoreOption, DriverOption]>,
HelpText<"Follow Vulkan spec to use gl_BaseVertex as the first vertex, which makes SV_VertexID = gl_VertexIndex - gl_BaseVertex (without this option, SV_VertexID = gl_VertexIndex)">;
def fvk_use_gl_layout: Flag<["-"], "fvk-use-gl-layout">, Group<spirv_Group>, Flags<[CoreOption, DriverOption]>,
HelpText<"Use strict OpenGL std140/std430 memory layout for Vulkan resources">;
def fvk_use_dx_layout: Flag<["-"], "fvk-use-dx-layout">, Group<spirv_Group>, Flags<[CoreOption, DriverOption]>,
Expand Down Expand Up @@ -412,8 +414,6 @@ def fspv_preserve_bindings : Flag<["-"], "fspv-preserve-bindings">, Group<spirv_
HelpText<"Preserves all bindings declared within the module, even when those bindings are unused">;
def fspv_preserve_interface : Flag<["-"], "fspv-preserve-interface">, Group<spirv_Group>, Flags<[CoreOption, DriverOption]>,
HelpText<"Preserves all interface variables in the entry point, even when those variables are unused">;
def fvk_allow_rwstructuredbuffer_arrays: Flag<["-"], "fvk-allow-rwstructuredbuffer-arrays">, Group<spirv_Group>, Flags<[CoreOption, DriverOption, HelpHidden]>,
HelpText<"Allow arrays of RWStructuredBuffers, AppendStructuredBuffers, and ConsumeStructuredBuffers. This is in development, and the option will be removed when the feature is complete.">;
def fspv_max_id : MultiArg<["-"], "fspv-max-id", 1>, MetaVarName<"<shift> <space>">, Group<spirv_Group>, Flags<[CoreOption, DriverOption]>,
HelpText<"Set the maximum value for an id in the SPIR-V binary. Default is 0x3FFFFF, which is the largest value all drivers must support.">;
// SPIRV Change Ends
Expand Down
2 changes: 1 addition & 1 deletion include/dxc/Support/SPIRVOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ struct SpirvCodeGenOptions {
bool reduceLoadSize;
bool autoShiftBindings;
bool supportNonzeroBaseInstance;
bool supportNonzeroBaseVertex;
bool fixFuncCallArguments;
bool allowRWStructuredBufferArrays;
bool enableMaximalReconvergence;
bool useVulkanMemoryModel;
bool IEEEStrict;
Expand Down
6 changes: 2 additions & 4 deletions lib/DxcSupport/HLSLOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,8 @@ int ReadDxcOpts(const OptTable *optionTable, unsigned flagsToInclude,
Args.hasFlag(OPT_fvk_use_dx_position_w, OPT_INVALID, false);
opts.SpirvOptions.supportNonzeroBaseInstance =
Args.hasFlag(OPT_fvk_support_nonzero_base_instance, OPT_INVALID, false);
opts.SpirvOptions.supportNonzeroBaseVertex =
Args.hasFlag(OPT_fvk_support_nonzero_base_vertex, OPT_INVALID, false);
opts.SpirvOptions.useGlLayout =
Args.hasFlag(OPT_fvk_use_gl_layout, OPT_INVALID, false);
opts.SpirvOptions.useDxLayout =
Expand Down Expand Up @@ -1081,8 +1083,6 @@ int ReadDxcOpts(const OptTable *optionTable, unsigned flagsToInclude,
Args.hasFlag(OPT_fspv_preserve_bindings, OPT_INVALID, false);
opts.SpirvOptions.preserveInterface =
Args.hasFlag(OPT_fspv_preserve_interface, OPT_INVALID, false);
opts.SpirvOptions.allowRWStructuredBufferArrays =
Args.hasFlag(OPT_fvk_allow_rwstructuredbuffer_arrays, OPT_INVALID, false);
opts.SpirvOptions.enableMaximalReconvergence =
Args.hasFlag(OPT_fspv_enable_maximal_reconvergence, OPT_INVALID, false);
opts.SpirvOptions.useVulkanMemoryModel =
Expand Down Expand Up @@ -1235,8 +1235,6 @@ int ReadDxcOpts(const OptTable *optionTable, unsigned flagsToInclude,
Args.hasFlag(OPT_Wno_vk_ignored_features, OPT_INVALID, false) ||
Args.hasFlag(OPT_Wno_vk_emulated_features, OPT_INVALID, false) ||
Args.hasFlag(OPT_fvk_auto_shift_bindings, OPT_INVALID, false) ||
Args.hasFlag(OPT_fvk_allow_rwstructuredbuffer_arrays, OPT_INVALID,
false) ||
!Args.getLastArgValue(OPT_fvk_stage_io_order_EQ).empty() ||
!Args.getLastArgValue(OPT_fspv_debug_EQ).empty() ||
!Args.getLastArgValue(OPT_fspv_extension_EQ).empty() ||
Expand Down
1 change: 1 addition & 0 deletions lib/DxilContainer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ add_llvm_library(LLVMDxilContainer
DxilContainerAssembler.cpp
DxilContainerReader.cpp
DxcContainerBuilder.cpp
DxilPipelineStateValidation.cpp
DxilRDATBuilder.cpp
DxilRuntimeReflection.cpp
RDATDumper.cpp
Expand Down
Loading

0 comments on commit 285a04c

Please sign in to comment.