Skip to content

Commit

Permalink
Merge branch 'main' into psv_size
Browse files Browse the repository at this point in the history
  • Loading branch information
python3kgae authored Oct 2, 2024
2 parents d8a04b0 + dfa1c81 commit ac98afd
Show file tree
Hide file tree
Showing 66 changed files with 1,877 additions and 90 deletions.
2 changes: 1 addition & 1 deletion docs/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ The included licenses apply to the following files:

| License file | Applies to |
|---|---|
|LICENSE-MS.txt |dxil.dll (if included in package)|
|LICENSE-MIT.txt |d3d12shader.h|
|LICENSE-LLVM.txt |all other files|

Expand All @@ -23,6 +22,7 @@ The included licenses apply to the following files:
Place release notes for the upcoming release below this line and remove this line upon naming this release.

- The incomplete WaveMatrix implementation has been removed.
- DXIL Validator Hash is open sourced.
- DXIL container validation for PSV0 part allows any content ordering inside string and semantic index tables.

### Version 1.8.2407
Expand Down
2 changes: 1 addition & 1 deletion external/SPIRV-Tools
Submodule SPIRV-Tools updated 53 files
+1 −1 .github/workflows/ios.yml
+3 −3 .github/workflows/scorecard.yml
+2 −0 Android.mk
+0 −1 BUILD.bazel
+5 −0 BUILD.gn
+14 −0 CHANGES
+3 −3 DEPS
+14 −0 MODULE.bazel
+1 −1 include/spirv-tools/libspirv.hpp
+9 −0 include/spirv-tools/optimizer.hpp
+2 −0 source/CMakeLists.txt
+1 −0 source/binary.cpp
+3 −12 source/name_mapper.cpp
+1 −0 source/opt/CMakeLists.txt
+4 −2 source/opt/aggressive_dead_code_elim_pass.cpp
+17 −3 source/opt/debug_info_manager.cpp
+2 −1 source/opt/inst_debug_printf_pass.cpp
+3 −2 source/opt/local_access_chain_convert_pass.cpp
+3 −2 source/opt/local_single_block_elim_pass.cpp
+3 −2 source/opt/local_single_store_elim_pass.cpp
+1 −0 source/opt/mem_pass.cpp
+28 −0 source/opt/optimizer.cpp
+1 −0 source/opt/passes.h
+6 −2 source/opt/remove_unused_interface_variables_pass.cpp
+482 −0 source/opt/struct_packing_pass.cpp
+81 −0 source/opt/struct_packing_pass.h
+2 −2 source/opt/trim_capabilities_pass.h
+44 −0 source/to_string.cpp
+29 −0 source/to_string.h
+1 −1 source/util/bitutils.h
+3 −0 source/val/validate_cfg.cpp
+1 −1 source/val/validate_decorations.cpp
+18 −12 source/val/validate_derivatives.cpp
+18 −12 source/val/validate_extensions.cpp
+53 −30 source/val/validate_image.cpp
+36 −7 source/val/validate_memory.cpp
+2 −0 source/val/validation_state.cpp
+1 −0 test/CMakeLists.txt
+10 −0 test/binary_to_text_test.cpp
+1 −0 test/opt/CMakeLists.txt
+39 −2 test/opt/aggressive_dead_code_elim_test.cpp
+78 −0 test/opt/debug_info_manager_test.cpp
+242 −0 test/opt/struct_packing_test.cpp
+14 −14 test/opt/trim_capabilities_pass_test.cpp
+28 −0 test/to_string_test.cpp
+37 −0 test/val/val_cfg_test.cpp
+73 −0 test/val/val_decoration_test.cpp
+5 −4 test/val/val_derivatives_test.cpp
+215 −25 test/val/val_image_test.cpp
+247 −19 test/val/val_memory_test.cpp
+4 −0 tools/opt/opt.cpp
+2 −1 utils/check_copyright.py
+5 −4 utils/update_build_version.py
13 changes: 8 additions & 5 deletions include/dxc/DxilContainer/DxilPipelineStateValidation.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,23 @@
#ifndef __DXIL_PIPELINE_STATE_VALIDATION__H__
#define __DXIL_PIPELINE_STATE_VALIDATION__H__

// ------ Don't unconditionally #include <assert.h> here --------
// Since this header is included from multiple environments,
// Conditionally include <assert.h> here is to avoid overwriting
// the assert that's using by the code which includes this header.
//

#include "dxc/WinAdapter.h"
#ifndef assert
#include <assert.h>
#endif
#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.
// #include <assert.h>

#ifndef UINT_MAX
#define UINT_MAX 0xffffffff
#endif
Expand Down
6 changes: 6 additions & 0 deletions include/dxc/Support/HLSLOptions.td
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,12 @@ def fspv_preserve_interface : Flag<["-"], "fspv-preserve-interface">, Group<spir
HelpText<"Preserves all interface variables in the entry point, even when those variables are unused">;
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.">;
def fvk_bind_resource_heap : MultiArg<["-"], "fvk-bind-resource-heap", 2>, MetaVarName<"<binding> <set>">, Group<spirv_Group>, Flags<[CoreOption, DriverOption]>,
HelpText<"Specify Vulkan binding number and set number for the resource heap.">;
def fvk_bind_sampler_heap : MultiArg<["-"], "fvk-bind-sampler-heap", 2>, MetaVarName<"<binding> <set>">, Group<spirv_Group>, Flags<[CoreOption, DriverOption]>,
HelpText<"Specify Vulkan binding number and set number for the sampler heap.">;
def fvk_bind_counter_heap : MultiArg<["-"], "fvk-bind-counter-heap", 2>, MetaVarName<"<binding> <set>">, Group<spirv_Group>, Flags<[CoreOption, DriverOption]>,
HelpText<"Specify Vulkan binding number and set number for the counter heap.">;
// SPIRV Change Ends

//////////////////////////////////////////////////////////////////////////////
Expand Down
11 changes: 11 additions & 0 deletions include/dxc/Support/SPIRVOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/Option/ArgList.h"

#include <optional>

namespace clang {
namespace spirv {

Expand Down Expand Up @@ -97,6 +99,15 @@ struct SpirvCodeGenOptions {
std::string entrypointName;
std::string floatDenormalMode; // OPT_denorm

// User-defined bindings/set numbers for resource/sampler/counter heaps.
struct BindingInfo {
size_t binding;
size_t set;
};
std::optional<BindingInfo> resourceHeapBinding;
std::optional<BindingInfo> samplerHeapBinding;
std::optional<BindingInfo> counterHeapBinding;

bool signaturePacking; ///< Whether signature packing is enabled or not

bool printAll; // Dump SPIR-V module before each pass and after the last one.
Expand Down
62 changes: 61 additions & 1 deletion lib/DxcSupport/HLSLOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,15 @@
#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"

#include <optional>

using namespace llvm::opt;
using namespace dxc;
using namespace hlsl;
using namespace hlsl::options;
#ifdef ENABLE_SPIRV_CODEGEN
using namespace clang::spirv;
#endif

#define PREFIX(NAME, VALUE) static const char *const NAME[] = VALUE;
#include "dxc/Support/HLSLOptions.inc"
Expand Down Expand Up @@ -320,6 +325,46 @@ static bool handleVkShiftArgs(const InputArgList &args, OptSpecifier id,
return true;
}

// Parses the given flag |id| in |args|. If present and valid, sets |info| to
// the correct value. Returns true if parsing succeeded. Returns false if
// parsing failed, and outputs in |errors| a message using |name| as pretty name
// for the flag.
static bool
handleFixedBinding(const InputArgList &args, OptSpecifier id,
std::optional<SpirvCodeGenOptions::BindingInfo> *info,
llvm::StringRef name, llvm::raw_ostream &errors) {
const auto values = args.getAllArgValues(id);
if (values.size() == 0) {
*info = std::nullopt;
return true;
}

if (!args.hasArg(OPT_spirv)) {
errors << name << " requires -spirv";
return false;
}

assert(values.size() == 2);

size_t output[2] = {0, 0};
for (unsigned i = 0; i < 2; ++i) {
int number = 0;
if (llvm::StringRef(values[i]).getAsInteger(10, number)) {
errors << "invalid " << name << " argument: '" << values[i] << "'";
return false;
}
if (number < 0) {
errors << "expected positive integer for " << name
<< ", got: " << values[i];
return false;
}
output[i] = number;
}

*info = {output[0], output[1]};
return true;
}

// Check if any options that are unsupported with SPIR-V are used.
static bool hasUnsupportedSpirvOption(const InputArgList &args,
llvm::raw_ostream &errors) {
Expand Down Expand Up @@ -1109,6 +1154,18 @@ int ReadDxcOpts(const OptTable *optionTable, unsigned flagsToInclude,
return 1;
}

if (!handleFixedBinding(Args, OPT_fvk_bind_resource_heap,
&opts.SpirvOptions.resourceHeapBinding,
"-fvk-bind-resource-heap", errors) ||
!handleFixedBinding(Args, OPT_fvk_bind_sampler_heap,
&opts.SpirvOptions.samplerHeapBinding,
"-fvk-bind-sampler-heap", errors) ||
!handleFixedBinding(Args, OPT_fvk_bind_counter_heap,
&opts.SpirvOptions.counterHeapBinding,
"-fvk-bind-counter-heap", errors)) {
return 1;
}

for (const Arg *A : Args.filtered(OPT_fspv_extension_EQ)) {
opts.SpirvOptions.allowedExtensions.push_back(A->getValue());
}
Expand Down Expand Up @@ -1245,7 +1302,10 @@ int ReadDxcOpts(const OptTable *optionTable, unsigned flagsToInclude,
!Args.getLastArgValue(OPT_fvk_b_shift).empty() ||
!Args.getLastArgValue(OPT_fvk_t_shift).empty() ||
!Args.getLastArgValue(OPT_fvk_s_shift).empty() ||
!Args.getLastArgValue(OPT_fvk_u_shift).empty()) {
!Args.getLastArgValue(OPT_fvk_u_shift).empty() ||
!Args.getLastArgValue(OPT_fvk_bind_resource_heap).empty() ||
!Args.getLastArgValue(OPT_fvk_bind_sampler_heap).empty() ||
!Args.getLastArgValue(OPT_fvk_bind_counter_heap).empty()) {
errors << "SPIR-V CodeGen not available. "
"Please recompile with -DENABLE_SPIRV_CODEGEN=ON.";
return 1;
Expand Down
4 changes: 2 additions & 2 deletions tools/clang/include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -7663,8 +7663,8 @@ def err_hlsl_unsupported_nested_typedef : Error<
def err_hlsl_unsupported_operator : Error<
"operator is not supported">;
// This error is unused because the HLSL parser will catch all cases.
//def err_hlsl_unsupported_string_literal : Error<
// "unsupported style of string literal - use a char-based literal">;
def err_hlsl_unsupported_string_literal : Error<
"string literals parameters are not supported in HLSL">;
def err_hlsl_unsupported_struct_op: Error<
"operator cannot be used with user-defined type %0">;
def err_hlsl_unsupported_subscript_base_rhs : Error<
Expand Down
4 changes: 2 additions & 2 deletions tools/clang/lib/AST/NestedNameSpecifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ operator=(const NestedNameSpecifierLocBuilder &Other) {

// Free our storage, if we have any.
if (BufferCapacity) {
free(Buffer);
delete[] Buffer; // HLSL Change: Use overridable operator delete
BufferCapacity = 0;
}

Expand Down Expand Up @@ -647,7 +647,7 @@ void NestedNameSpecifierLocBuilder::MakeTrivial(ASTContext &Context,

void NestedNameSpecifierLocBuilder::Adopt(NestedNameSpecifierLoc Other) {
if (BufferCapacity)
free(Buffer);
delete[] Buffer; // HLSL Change: Use overridable operator delete

if (!Other) {
Representation = nullptr;
Expand Down
Loading

0 comments on commit ac98afd

Please sign in to comment.